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

Skip to content

Commit e343878

Browse files
committed
New news about __class__ assignment restrictions and speed-up of
new-style object creation/deallocation. Moved all news about type/class unification and new-stype classes to a separate section at the top.
1 parent 6c70fca commit e343878

1 file changed

Lines changed: 51 additions & 43 deletions

File tree

Misc/NEWS

Lines changed: 51 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,57 @@ XXX Release date: DD-MMM-2002 XXX
44

55
Type/class unification and new-style classes
66

7+
- Assignment to __class__ is disallowed if either the old and the new
8+
class is a statically allocated type object (such as defined by an
9+
extenson module). This prevents anomalies like 2.__class__ = bool.
10+
11+
- New-style object creation and deallocation have been sped up
12+
significantly; they are now faster than classic instance creation
13+
and deallocation.
14+
15+
- The __slots__ variable can now mention "private" names, and the
16+
right thing will happen (e.g. __slots__ = ["__foo"]).
17+
18+
- The built-ins slice() and buffer() are now callable types. The
19+
types classobj (formerly class), code, function, instance, and
20+
instancemethod (formerly instance-method), which have no built-in
21+
names but are accessible through the types module, are now also
22+
callable. The type dict-proxy is renamed to dictproxy.
23+
24+
- Cycles going through the __class__ link of a new-style instance are
25+
now detected by the garbage collector.
26+
27+
- Classes using __slots__ are now properly garbage collected.
28+
[SF bug 519621]
29+
30+
- Tightened the __slots__ rules: a slot name must be a valid Python
31+
identifier.
32+
33+
- The constructor for the module type now requires a name argument and
34+
takes an optional docstring argument. Previously, this constructor
35+
ignored its arguments. As a consequence, deriving a class from a
36+
module (not from the module type) is now illegal; previously this
37+
created an unnamed module, just like invoking the module type did.
38+
[SF bug 563060]
39+
40+
- A new type object, 'basestring', is added. This is a common base type
41+
for 'str' and 'unicode', and can be used instead of
42+
types.StringTypes, e.g. to test whether something is "a string":
43+
isinstance(x, basestring) is True for Unicode and 8-bit strings. This
44+
is an abstract base class and cannot be instantiated directly.
45+
46+
- Changed new-style class instantiation so that when C's __new__
47+
method returns something that's not a C instance, its __init__ is
48+
not called. [SF bug #537450]
49+
50+
- Fixed super() to work correctly with class methods. [SF bug #535444]
51+
52+
- If you try to pickle an instance of a class that has __slots__ but
53+
doesn't define or override __getstate__, a TypeError is now raised.
54+
This is done by adding a bozo __getstate__ to the class that always
55+
raises TypeError. (Before, this would appear to be pickled, but the
56+
state of the slots would be lost.)
57+
758
Core and builtins
859

960
- XXX Karatsuba multiplication. This is currently used if and only
@@ -80,18 +131,9 @@ Core and builtins
80131
but a buffer object would be returned when the repetition count
81132
was one or when the slice range was all inclusive.
82133

83-
- The __slots__ variable can now mention "private" names, and the
84-
right thing will happen (e.g. __slots__ = ["__foo"]).
85-
86134
- Unicode objects in sys.path are no longer ignored but treated
87135
as directory names.
88136

89-
- The built-ins slice() and buffer() are now callable types. The
90-
types classobj (formerly class), code, function, instance, and
91-
instancemethod (formerly instance-method), which have no built-in
92-
names but are accessible through the types module, are now also
93-
callable. The type dict-proxy is renamed to dictproxy.
94-
95137
- Fixed string.startswith and string.endswith builtin methods
96138
so they accept negative indices. [SF bug 493951]
97139

@@ -102,34 +144,12 @@ Core and builtins
102144
with a third "stride" parameter. For example, "hello world"[::-1]
103145
gives "dlrow olleh".
104146

105-
- Cycles going through the __class__ link of a new-style instance are
106-
now detected by the garbage collector.
107-
108-
- Classes using __slots__ are now properly garbage collected.
109-
[SF bug 519621]
110-
111-
- Tightened the __slots__ rules: a slot name must be a valid Python
112-
identifier.
113-
114-
- The constructor for the module type now requires a name argument and
115-
takes an optional docstring argument. Previously, this constructor
116-
ignored its arguments. As a consequence, deriving a class from a
117-
module (not from the module type) is now illegal; previously this
118-
created an unnamed module, just like invoking the module type did.
119-
[SF bug 563060]
120-
121147
- A new warning PendingDeprecationWarning was added to provide
122148
direction on features which are in the process of being deprecated.
123149
The warning will not be printed by default. To see the pending
124150
deprecations, use -Walways::PendingDeprecationWarning::
125151
as a command line option or warnings.filterwarnings() in code.
126152

127-
- A new type object, 'basestring', is added. This is a common base type
128-
for 'str' and 'unicode', and can be used instead of
129-
types.StringTypes, e.g. to test whether something is "a string":
130-
isinstance(x, basestring) is True for Unicode and 8-bit strings. This
131-
is an abstract base class and cannot be instantiated directly.
132-
133153
- Deprecated features of xrange objects have been removed as
134154
promised. The start, stop, and step attributes and the tolist()
135155
method no longer exist. xrange repetition and slicing have been
@@ -158,12 +178,6 @@ Core and builtins
158178
- Added a new dict method pop(key). This removes and returns the
159179
value corresponding to key. [SF patch #539949]
160180

161-
- Changed new-style class instantiation so that when C's __new__
162-
method returns something that's not a C instance, its __init__ is
163-
not called. [SF bug #537450]
164-
165-
- Fixed super() to work correctly with class methods. [SF bug #535444]
166-
167181
- A new built-in type, bool, has been added, as well as built-in
168182
names for its two values, True and False. Comparisons and sundry
169183
other operations that return a truth value have been changed to
@@ -183,12 +197,6 @@ Core and builtins
183197
and lets them use the same API with Python versions from 1.5.2
184198
onwards.
185199

186-
- If you try to pickle an instance of a class that has __slots__ but
187-
doesn't define or override __getstate__, a TypeError is now raised.
188-
This is done by adding a bozo __getstate__ to the class that always
189-
raises TypeError. (Before, this would appear to be pickled, but the
190-
state of the slots would be lost.)
191-
192200
- PyErr_Display will provide file and line information for all exceptions
193201
that have an attribute print_file_and_line, not just SyntaxErrors.
194202

0 commit comments

Comments
 (0)