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