Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23e8db5

Browse files
committed
#2567: remove new-style/old-style class docs.
1 parent dc21db3 commit 23e8db5

6 files changed

Lines changed: 13 additions & 78 deletions

File tree

Doc/c-api/typeobj.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,7 @@ set.
730730

731731
An optional pointer to a function that returns an iterator for the object. Its
732732
presence normally signals that the instances of this type are iterable (although
733-
sequences may be iterable without this function, and classic instances always
734-
have this function, even if they don't define an :meth:`__iter__` method).
733+
sequences may be iterable without this function).
735734

736735
This function has the same signature as :cfunc:`PyObject_GetIter`.
737736

@@ -742,9 +741,7 @@ set.
742741

743742
An optional pointer to a function that returns the next item in an iterator, or
744743
raises :exc:`StopIteration` when the iterator is exhausted. Its presence
745-
normally signals that the instances of this type are iterators (although classic
746-
instances always have this function, even if they don't define a
747-
:meth:`__next__` method).
744+
normally signals that the instances of this type are iterators.
748745

749746
Iterator types should also define the :attr:`tp_iter` function, and that
750747
function should return the iterator instance itself (not a new iterator

Doc/glossary.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ Glossary
3939
"intermediate language" is said to run on a "virtual machine" that calls
4040
the subroutines corresponding to each bytecode.
4141

42-
classic class
43-
One of the two flavors of classes in earlier Python versions. Since
44-
Python 3.0, there are no classic classes anymore.
45-
4642
complex number
4743
An extension of the familiar real number system in which all numbers are
4844
expressed as a sum of a real part and an imaginary part. Imaginary
@@ -367,8 +363,6 @@ Glossary
367363
versatile features like :attr:`__slots__`, descriptors, properties,
368364
:meth:`__getattribute__`, class methods, and static methods.
369365

370-
More information can be found in :ref:`newstyle`.
371-
372366
positional argument
373367
The arguments assigned to local names inside a function or method,
374368
determined by the order in which they were given in the call. ``*`` is

Doc/library/copy_reg.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ instances.
2626

2727
.. function:: pickle(type, function[, constructor])
2828

29-
Declares that *function* should be used as a "reduction" function for objects of
30-
type *type*; *type* must not be a "classic" class object. (Classic classes are
31-
handled differently; see the documentation for the :mod:`pickle` module for
32-
details.) *function* should return either a string or a tuple containing two or
33-
three elements.
29+
Declares that *function* should be used as a "reduction" function for objects
30+
of type *type*. *function* should return either a string or a tuple
31+
containing two or three elements.
3432

3533
The optional *constructor* parameter, if provided, is a callable object which
3634
can be used to reconstruct the object when called with the tuple of arguments

Doc/library/pickle.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ Pickling and unpickling normal class instances
403403
single: __init__() (instance constructor)
404404

405405
.. XXX is __getinitargs__ only used with old-style classes?
406+
.. XXX update w.r.t Py3k's classes
406407
407408
When a pickled class instance is unpickled, its :meth:`__init__` method is
408409
normally *not* invoked. If it is desirable that the :meth:`__init__` method be
@@ -447,8 +448,8 @@ can do what they want. [#]_
447448

448449
.. warning::
449450

450-
For :term:`new-style class`\es, if :meth:`__getstate__` returns a false
451-
value, the :meth:`__setstate__` method will not be called.
451+
If :meth:`__getstate__` returns a false value, the :meth:`__setstate__`
452+
method will not be called.
452453

453454

454455
Pickling and unpickling extension types

Doc/reference/compound_stmts.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -577,9 +577,8 @@ can be set in a method with ``self.name = value``. Both class and instance
577577
variables are accessible through the notation "``self.name``", and an instance
578578
variable hides a class variable with the same name when accessed in this way.
579579
Class variables can be used as defaults for instance variables, but using
580-
mutable values there can lead to unexpected results. For :term:`new-style
581-
class`\es, descriptors can be used to create instance variables with different
582-
implementation details.
580+
mutable values there can lead to unexpected results. Descriptors can be used
581+
to create instance variables with different implementation details.
583582

584583
.. XXX add link to descriptor docs above
585584

Doc/reference/datamodel.rst

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -980,45 +980,6 @@ Internal types
980980
by the built-in :func:`classmethod` constructor.
981981

982982

983-
.. _newstyle:
984-
985-
New-style and classic classes
986-
=============================
987-
988-
Classes and instances come in two flavors: old-style or classic, and new-style.
989-
990-
Up to Python 2.1, old-style classes were the only flavour available to the user.
991-
The concept of (old-style) class is unrelated to the concept of type: if *x* is
992-
an instance of an old-style class, then ``x.__class__`` designates the class of
993-
*x*, but ``type(x)`` is always ``<type 'instance'>``. This reflects the fact
994-
that all old-style instances, independently of their class, are implemented with
995-
a single built-in type, called ``instance``.
996-
997-
New-style classes were introduced in Python 2.2 to unify classes and types. A
998-
new-style class is neither more nor less than a user-defined type. If *x* is an
999-
instance of a new-style class, then ``type(x)`` is the same as ``x.__class__``.
1000-
1001-
The major motivation for introducing new-style classes is to provide a unified
1002-
object model with a full meta-model. It also has a number of immediate
1003-
benefits, like the ability to subclass most built-in types, or the introduction
1004-
of "descriptors", which enable computed properties.
1005-
1006-
For compatibility reasons, classes are still old-style by default. New-style
1007-
classes are created by specifying another new-style class (i.e. a type) as a
1008-
parent class, or the "top-level type" :class:`object` if no other parent is
1009-
needed. The behaviour of new-style classes differs from that of old-style
1010-
classes in a number of important details in addition to what :func:`type`
1011-
returns. Some of these changes are fundamental to the new object model, like
1012-
the way special methods are invoked. Others are "fixes" that could not be
1013-
implemented before for compatibility concerns, like the method resolution order
1014-
in case of multiple inheritance.
1015-
1016-
This manual is not up-to-date with respect to new-style classes. For now,
1017-
please see http://www.python.org/doc/newstyle/ for more information.
1018-
1019-
.. XXX remove old style classes from docs
1020-
1021-
1022983
.. _specialnames:
1023984

1024985
Special method names
@@ -1418,9 +1379,7 @@ continuing through the base classes of ``type(a)`` excluding metaclasses.
14181379
However, if the looked-up value is an object defining one of the descriptor
14191380
methods, then Python may override the default behavior and invoke the descriptor
14201381
method instead. Where this occurs in the precedence chain depends on which
1421-
descriptor methods were defined and how they were called. Note that descriptors
1422-
are only invoked for new style objects or classes (ones that subclass
1423-
:class:`object()` or :class:`type()`).
1382+
descriptor methods were defined and how they were called.
14241383

14251384
The starting point for descriptor invocation is a binding, ``a.x``. How the
14261385
arguments are assembled depends on ``a``:
@@ -1477,7 +1436,7 @@ saved because *__dict__* is not created for each instance.
14771436
.. data:: object.__slots__
14781437

14791438
This class variable can be assigned a string, iterable, or sequence of
1480-
strings with variable names used by instances. If defined in a new-style
1439+
strings with variable names used by instances. If defined in a
14811440
class, *__slots__* reserves space for the declared variables and prevents the
14821441
automatic creation of *__dict__* and *__weakref__* for each instance.
14831442

@@ -1801,7 +1760,7 @@ left undefined.
18011760
``-``, ``*``, ``/``, ``%``, :func:`divmod`, :func:`pow`, ``**``, ``<<``, ``>>``,
18021761
``&``, ``^``, ``|``) with reflected (swapped) operands. These functions are
18031762
only called if the left operand does not support the corresponding operation and
1804-
the operands are of different types. [#]_ For instance, to evaluate the
1763+
the operands are of different types. [#]_ For instance, to evaluate the
18051764
expression *x*``-``*y*, where *y* is an instance of a class that has an
18061765
:meth:`__rsub__` method, ``y.__rsub__(x)`` is called if ``x.__sub__(y)`` returns
18071766
*NotImplemented*.
@@ -1927,18 +1886,6 @@ For more information on context managers, see :ref:`typecontextmanager`.
19271886

19281887
.. rubric:: Footnotes
19291888

1930-
.. [#] Since Python 2.2, a gradual merging of types and classes has been started that
1931-
makes this and a few other assertions made in this manual not 100% accurate and
1932-
complete: for example, it *is* now possible in some cases to change an object's
1933-
type, under certain controlled conditions. Until this manual undergoes
1934-
extensive revision, it must now be taken as authoritative only regarding
1935-
"classic classes", that are still the default, for compatibility purposes, in
1936-
Python 2.2 and 2.3. For more information, see
1937-
http://www.python.org/doc/newstyle/.
1938-
1939-
.. [#] This, and other statements, are only roughly true for instances of new-style
1940-
classes.
1941-
19421889
.. [#] A descriptor can define any combination of :meth:`__get__`,
19431890
:meth:`__set__` and :meth:`__delete__`. If it does not define :meth:`__get__`,
19441891
then accessing the attribute even on an instance will return the descriptor
@@ -1949,4 +1896,3 @@ For more information on context managers, see :ref:`typecontextmanager`.
19491896
.. [#] For operands of the same type, it is assumed that if the non-reflected method
19501897
(such as :meth:`__add__`) fails the operation is not supported, which is why the
19511898
reflected method is not called.
1952-

0 commit comments

Comments
 (0)