blob: fc07e3fbcceee477d42c60cbfaf769e6519ca784 [file] [log] [blame]
Tim Peters6d6c1a32001-08-02 04:15:00 +00001Project: core implementation
2****************************
3
Guido van Rossumeb9f3842001-08-30 21:18:04 +00004Still to do
5-----------
Tim Peters6d6c1a32001-08-02 04:15:00 +00006
7Fix comparisons. There's some nasty stuff here: when two types are
8not the same, and they're not instances, the fallback code doesn't
9account for the possibility that they might be subtypes of a common
10base type that defines a comparison.
11
Guido van Rossumeb9f3842001-08-30 21:18:04 +000012Check for conflicts between base classes. I fear that the rules used
13to decide whether multiple bases have conflicting instance variables
14aren't strict enough. I think that sometimes two different classes
15adding __dict__ may be incompatible after all.
16
17Check for order conflicts. Suppose there are two base classes X and
18Y. Suppose class B derives from X and Y, and class C from Y and X (in
19that order). Now suppose class D derives from B and C. In which
20order should the base classes X and Y be searched? This is an order
21conflict, and should be disallowed; currently the test for this is not
22implemented.
23
Guido van Rossum531cf172001-09-10 02:40:26 +000024Allow __class__ assignment (and __bases__ and __dict__?).
Guido van Rossumeb9f3842001-08-30 21:18:04 +000025
26Make __dynamic__ the default.
27
28Add __del__ handlers.
29
Guido van Rossum531cf172001-09-10 02:40:26 +000030Add __coerce__?
31
32Support pickling (via __reduce__?)
33
Guido van Rossum531cf172001-09-10 02:40:26 +000034Support mixed multiple inheritance from classic and new-style classes?
35
36Change __getattr__ to be more like classic __getattr__, and introduce
37a new name for new-style __getattr__?
38
Guido van Rossumeb9f3842001-08-30 21:18:04 +000039Done (mostly)
40-------------
41
Guido van Rossumed8fa722001-09-20 05:27:24 +000042Make inspect and pydoc do the right thing for new-style classes. ***
43done ***
44
Guido van Rossumeb9f3842001-08-30 21:18:04 +000045Do binary operators properly. nb_add should try to call self.__add__
46and other.__radd__. I think I'll exclude base types that define any
47binary operator without setting the CHECKTYPES flag. *** This is
48done, AFAICT. Even supports __truediv__ and __floordiv__. ***
49
Tim Peters6d6c1a32001-08-02 04:15:00 +000050Fix subtype_dealloc(). This currently searches through the list of
51base types until it finds a type whose tp_dealloc is not
52subtype_dealloc. I think this is not safe. I think the alloc/dealloc
53policy needs to be rethought. *** There's an idea here that I haven't
54worked out yet: just as object creation now has separate API's tp_new,
55tp_alloc, and tp_init, destruction has tp_dealloc and tp_free. (Maybe
56tp_fini should be added to correspond to tp_init?) Something
57could/should be done with this. ***
58
59Clean up isinstance(), issubclass() and their C equivalents. There
60are a bunch of different APIs here and not all of them do the right
61thing yet. There should be fewer APIs and their implementation should
62be simpler. The old "abstract subclass" test should probably
63disappear (if we want to root out ExtensionClass). *** I think I've
64done 90% of this by creating PyType_IsSubtype() and using it
65appropriately. For now, the old "abstract subclass" test is still
66there, and there may be some places where PyObject_IsSubclass() is
67called where PyType_IsSubtype() would be more appropriate. ***
68
Tim Peters6d6c1a32001-08-02 04:15:00 +000069Clean up the GC interface. Currently, tp_basicsize includes the GC
70head size iff tp_flags includes the GC flag bit. This makes object
71size math a pain (e.g. to see if two object types have the same
72instance size, you can't just compare the tp_basicsize fields -- you
73have to conditionally subtract the GC head size). Neil has a patch
74that improves the API in this area, but it's backwards incompatible.
75(http://sf.net/tracker/?func=detail&aid=421893&group_id=5470&atid=305470)
76I think I know of a way to fix the incompatibility (by switching to a
77different flag bit). *** Tim proposed a better idea: macros to access
78tp_basicsize while hiding the nastiness. This is done now, so I think
Guido van Rossumeb9f3842001-08-30 21:18:04 +000079the rest of this task needn't be done. *** *** Neil checked in a
80much improved version of his idea, and it's all squared away. ***
Tim Peters6d6c1a32001-08-02 04:15:00 +000081
82Make the __dict__ of types declared with Python class statements
83writable -- only statically declared types must have an immutable
84dict, because they're shared between interpreter instances. Possibly
85trap writes to the __dict__ to update the corresponding tp_<slot> if
86an __<slot>__ name is affected. *** Done as part of the next task. ***
87
88It should be an option (maybe a different metaclass, maybe a flag) to
89*not* merge __dict__ with all the bases, but instead search the
90__dict__ (or __introduced__?) of all bases in __mro__ order. (This is
91needed anyway to unify classes completely.) *** Partly done.
92Inheritance of slots from bases is still icky: (1) MRO is not always
93respected when inheriting slots; (2) dynamic classes can't add slot
94implementations in Python after creation (e.g., setting C.__hash__
95doesn't set the tp_hash slot). ***
96
97Universal base class (object). How can we make the object class
98subclassable and define simple default methods for everything without
99having these inherited by built-in types that don't want these
100defaults? *** Done, really. ***
101
102Add error checking to the MRO calculation. *** Done. ***
103
104Make __new__ overridable through a Python class method (!). Make more
105of the sub-algorithms of type construction available as methods. ***
106After I implemented class methods, I found that in order to be able
107to make an upcall to Base.__new__() and have it create an instance of
108your class (rather than a Base instance), you can't use class methods
109-- you must use static methods. So I've implemented those too. I've
110hooked up __new__ in the right places, so the first part of this is
111now done. I've also exported the MRO calculation and made it
112overridable, as metamethod mro(). I believe that closes this topic
113for now. I expect that some warts will only be really debugged when
114we try to use this for some, eh, interesting types such as tuples. ***
115
Guido van Rossum04156202001-08-08 16:57:43 +0000116 There was a sequel to the __new__ story (see checkins). There
117 still is a problem: object.__new__ now no longer exists, because
118 it was inherited by certain extension types that could break. But
119 now when I write
120
121 class C(object):
122 def __new__(cls, *args):
123 "How do I call the default __new__ implementation???"
124
Guido van Rossum42a8c2b2001-08-09 20:25:58 +0000125 This was resolved nicely by putting object.__new__ back but not
126 inheriting __new__ from object when the subtype is a built-in or
127 extension type.
128
Tim Peters6d6c1a32001-08-02 04:15:00 +0000129More -- I'm sure new issues will crop up as we go.
130
131
132Project: loose ends and follow-through
133**************************************
134
Guido van Rossumeb9f3842001-08-30 21:18:04 +0000135Still to do
136-----------
Tim Peters6d6c1a32001-08-02 04:15:00 +0000137
138Exceptions should be types. This changes the rules, since now almost
139anything can be raised (as maybe it should). Or should we strive for
140enforcement of the convention that all exceptions should be derived
141from Exception? String exceptions will be another hassle, to be
142deprecated and eventually ruled out.
143
144Standardize a module containing names for all built-in types, and
145standardize on names. E.g. should the official name of the string
146type be 'str', 'string', or 'StringType'?
147
148Create a hierarchy of types, so that e.g. int and long are both
149subtypes of an abstract base type integer, which is itself a subtype
150of number, etc. A lot of thinking can go into this!
151
152*** NEW TASK??? ***
153Implement "signature" objects. These are alluded to in PEP 252 but
154not yet specified. Supposedly they provide an easily usable API to
155find out about function/method arguments. Building these for Python
156functions is simple. Building these for built-in functions will
157require a change to the PyMethodDef structure, so that a type can
158provide signature information for its C methods. (This would also
159help in supporting keyword arguments for C methods with less work than
160PyArg_ParseTupleAndKeywords() currently requires.) But should we do
161this? It's additional work and not required for any of the other
162parts.
163
Guido van Rossumeb9f3842001-08-30 21:18:04 +0000164Done (mostly)
165-------------
166
167Make more (most?) built-in types act as their own factory functions.
168*** Done for all reasonable built-in types. ***
169
170Make more (most?) built-in types subtypable -- with or without
171overridable allocation. *** This includes descriptors! It should be
172possible to write descriptors in Python, so metaclasses can do clever
173things with them. *** *** Done for most reasonable built-in types,
174except for descriptors ***
175
Tim Peters6d6c1a32001-08-02 04:15:00 +0000176
177Project: making classes use the new machinery
178*********************************************
179
180Tasks:
181
182Try to get rid of all code in classobject.c by deferring to the new
183mechanisms. How far can we get without breaking backwards
184compatibility? This is underspecified because I haven't thought much
185about it yet. Can we lose the use of PyInstance_Check() everywhere?
Guido van Rossumeb9f3842001-08-30 21:18:04 +0000186I would hope so! *** I'm dropping this goal for now -- classic
187classes will be 99% unchanged. ***
Tim Peters6d6c1a32001-08-02 04:15:00 +0000188
189
190Project: backwards compatibility
191********************************
192
193Tasks:
194
195Make sure all code checks the proper tp_flags bit before accessing
196type object fields.
197
198Identify areas of incompatibility with Python 2.1. Design solutions.
199Implement and test.
200
201Some specific areas: a fair amount of code probably depends on
202specific types having __members__ and/or __methods__ attributes.
203These are currently not present (conformant to PEP 252, which proposes
204to drop them) but we may have to add them back. This can be done in a
205generic way with not too much effort. Tim adds: Perhaps that dir(object)
206rarely returns anything but [] now is a consequence of this. I'm very
207used to doing, e.g., dir([]) or dir("") in an interactive shell to jog my
208memory; also one of the reasons test_generators failed.
209
210Another area: going all the way with classes and instances means that
211type(x) == types.InstanceType won't work any more to detect instances.
212Should there be a mode where this still works? Maybe this should be
213the default mode, with a warning, and an explicit way to get the new
214way to work? (Instead of a __future__ statement, I'm thinking of a
215module global __metaclass__ which would provide the default metaclass
216for baseless class statements.)
217
218
219Project: testing
220****************
221
222Tasks:
223
224Identify new functionality that needs testing. Conceive unit tests
225for all new functionality. Conceive stress tests for critical
226features. Run the tests. Fix bugs. Repeat until satisfied.
227
228Note: this may interact with the branch integration task.
229
230
Tim Petersf9803012001-08-02 22:06:35 +0000231Project: integration with main branch *** This is done - tim ***
Tim Peters6d6c1a32001-08-02 04:15:00 +0000232*************************************
233
234Tasks:
235
236Merge changes in the HEAD branch into the descr-branch. Then merge
237the descr-branch back into the HEAD branch.
238
239The longer we wait, the more effort this will be -- the descr-branch
240forked off quite a long time ago, and there are changes everywhere in
241the HEAD branch (e.g. the dict object has been radically rewritten).
242
243On the other hand, if we do this too early, we'll have to do it again
244later.
245
246Note from Tim: We should never again wait until literally 100s of files
247are out of synch. I don't care how often I need to do this, provided only
248that it's a tractable task each time. Once per week sounds like a good
249idea. As is, even the trunk change to rangeobject.c created more than its
250proper share of merge headaches, because it confused all the other reasons
251include file merges were getting conflicts (the more changes there are, the
252worse diff does; indeed, I came up with the ndiff algorithm in the 80s
253precisely because the source-control diff program Cray used at the time
254produced minimal but *senseless* diffs, thus creating artificial conflicts;
255paying unbounded attention to context does a much better job of putting
256changes where they make semantic sense too; but we're stuck with Unix diff
257here, and it isn't robust in this sense; if we don't keep its job simple,
258it will make my job hell).
259
260Done:
261To undo or rename before final merge: Modules/spam.c has worked its
262way into the branch Unix and Windows builds (pythoncore.dsp and
263PC/config.c); also imported by test_descr.py. How about renaming to
Tim Petersf9803012001-08-02 22:06:35 +0000264xxsubtype.c (whatever) now? *** this is done - tim ***
Tim Peters6d6c1a32001-08-02 04:15:00 +0000265
266
267Project: performance tuning
268***************************
269
270Tasks:
271
272Pick or create a general performance benchmark for Python. Benchmark
273the new system vs. the old system. Profile the new system. Improve
274hotspots. Repeat until satisfied.
275
276Note: this may interact with the branch integration task.
277
278
279Project: documentation
280**********************
281
282Tasks:
283
284Update PEP 252 (descriptors). Describe more of the prototype
285implementation
286
287Update PEP 253 (subtyping). Complicated architectural wrangling with
288metaclasses. There is an interaction between implementation and
289description.
290
291Write PEP 254 (unification of classes). This should discuss what
292changes for ordinary classes, and how we can make it more b/w
293compatible.
294
295Other documentation. There needs to be user documentation,
296eventually.
297
298
299Project: community interaction
300******************************
301
302Tasks:
303
304Once the PEPs are written, solicit community feedback, and formulate
305responses to the feedback. Give the community enough time to think
306over this complicated proposal. Provide the community with a
307prototype implementation to test. Try to do this *before* casting
308everything in stone!