blob: 23f48948c68a156ca857ef2f032368516f2eb2c4 [file] [log] [blame]
Tim Peters6d6c1a32001-08-02 04:15:00 +00001Project: core implementation
2****************************
3
4Tasks:
5
6Do binary operators properly. nb_add should try to call self.__add__
7and other.__radd__. I think I'll exclude base types that define any
Guido van Rossum396c0322001-08-08 22:51:13 +00008binary operator without setting the CHECKTYPES flag. *** This is
9done, AFAICT. Even supports __truediv__ and __floordiv__. ***
Tim Peters6d6c1a32001-08-02 04:15:00 +000010
11Fix comparisons. There's some nasty stuff here: when two types are
12not the same, and they're not instances, the fallback code doesn't
13account for the possibility that they might be subtypes of a common
14base type that defines a comparison.
15
16Fix subtype_dealloc(). This currently searches through the list of
17base types until it finds a type whose tp_dealloc is not
18subtype_dealloc. I think this is not safe. I think the alloc/dealloc
19policy needs to be rethought. *** There's an idea here that I haven't
20worked out yet: just as object creation now has separate API's tp_new,
21tp_alloc, and tp_init, destruction has tp_dealloc and tp_free. (Maybe
22tp_fini should be added to correspond to tp_init?) Something
23could/should be done with this. ***
24
25Clean up isinstance(), issubclass() and their C equivalents. There
26are a bunch of different APIs here and not all of them do the right
27thing yet. There should be fewer APIs and their implementation should
28be simpler. The old "abstract subclass" test should probably
29disappear (if we want to root out ExtensionClass). *** I think I've
30done 90% of this by creating PyType_IsSubtype() and using it
31appropriately. For now, the old "abstract subclass" test is still
32there, and there may be some places where PyObject_IsSubclass() is
33called where PyType_IsSubtype() would be more appropriate. ***
34
35Check for conflicts between base classes. I fear that the rules used
36to decide whether multiple bases have conflicting instance variables
37aren't strict enough. I think that sometimes two different classes
38adding __dict__ may be incompatible after all.
39
40Check for order conflicts. Suppose there are two base classes X and
41Y. Suppose class B derives from X and Y, and class C from Y and X (in
42that order). Now suppose class D derives from B and C. In which
43order should the base classes X and Y be searched? This is an order
44conflict, and should be disallowed; currently the test for this is not
45implemented.
46
47Clean up the GC interface. Currently, tp_basicsize includes the GC
48head size iff tp_flags includes the GC flag bit. This makes object
49size math a pain (e.g. to see if two object types have the same
50instance size, you can't just compare the tp_basicsize fields -- you
51have to conditionally subtract the GC head size). Neil has a patch
52that improves the API in this area, but it's backwards incompatible.
53(http://sf.net/tracker/?func=detail&aid=421893&group_id=5470&atid=305470)
54I think I know of a way to fix the incompatibility (by switching to a
55different flag bit). *** Tim proposed a better idea: macros to access
56tp_basicsize while hiding the nastiness. This is done now, so I think
57the rest of this task needn't be done. ***
58
59Make the __dict__ of types declared with Python class statements
60writable -- only statically declared types must have an immutable
61dict, because they're shared between interpreter instances. Possibly
62trap writes to the __dict__ to update the corresponding tp_<slot> if
63an __<slot>__ name is affected. *** Done as part of the next task. ***
64
65It should be an option (maybe a different metaclass, maybe a flag) to
66*not* merge __dict__ with all the bases, but instead search the
67__dict__ (or __introduced__?) of all bases in __mro__ order. (This is
68needed anyway to unify classes completely.) *** Partly done.
69Inheritance of slots from bases is still icky: (1) MRO is not always
70respected when inheriting slots; (2) dynamic classes can't add slot
71implementations in Python after creation (e.g., setting C.__hash__
72doesn't set the tp_hash slot). ***
73
74Universal base class (object). How can we make the object class
75subclassable and define simple default methods for everything without
76having these inherited by built-in types that don't want these
77defaults? *** Done, really. ***
78
79Add error checking to the MRO calculation. *** Done. ***
80
81Make __new__ overridable through a Python class method (!). Make more
82of the sub-algorithms of type construction available as methods. ***
83After I implemented class methods, I found that in order to be able
84to make an upcall to Base.__new__() and have it create an instance of
85your class (rather than a Base instance), you can't use class methods
86-- you must use static methods. So I've implemented those too. I've
87hooked up __new__ in the right places, so the first part of this is
88now done. I've also exported the MRO calculation and made it
89overridable, as metamethod mro(). I believe that closes this topic
90for now. I expect that some warts will only be really debugged when
91we try to use this for some, eh, interesting types such as tuples. ***
92
Guido van Rossum04156202001-08-08 16:57:43 +000093 There was a sequel to the __new__ story (see checkins). There
94 still is a problem: object.__new__ now no longer exists, because
95 it was inherited by certain extension types that could break. But
96 now when I write
97
98 class C(object):
99 def __new__(cls, *args):
100 "How do I call the default __new__ implementation???"
101
Guido van Rossum42a8c2b2001-08-09 20:25:58 +0000102 This was resolved nicely by putting object.__new__ back but not
103 inheriting __new__ from object when the subtype is a built-in or
104 extension type.
105
Tim Peters6d6c1a32001-08-02 04:15:00 +0000106More -- I'm sure new issues will crop up as we go.
107
108
109Project: loose ends and follow-through
110**************************************
111
112Tasks:
113
114Make more (most?) built-in types act as their own factory functions.
115
116Make more (most?) built-in types subtypable -- with or without
117overridable allocation. *** This includes descriptors! It should be
118possible to write descriptors in Python, so metaclasses can do clever
119things with them. ***
120
121Exceptions should be types. This changes the rules, since now almost
122anything can be raised (as maybe it should). Or should we strive for
123enforcement of the convention that all exceptions should be derived
124from Exception? String exceptions will be another hassle, to be
125deprecated and eventually ruled out.
126
127Standardize a module containing names for all built-in types, and
128standardize on names. E.g. should the official name of the string
129type be 'str', 'string', or 'StringType'?
130
131Create a hierarchy of types, so that e.g. int and long are both
132subtypes of an abstract base type integer, which is itself a subtype
133of number, etc. A lot of thinking can go into this!
134
135*** NEW TASK??? ***
136Implement "signature" objects. These are alluded to in PEP 252 but
137not yet specified. Supposedly they provide an easily usable API to
138find out about function/method arguments. Building these for Python
139functions is simple. Building these for built-in functions will
140require a change to the PyMethodDef structure, so that a type can
141provide signature information for its C methods. (This would also
142help in supporting keyword arguments for C methods with less work than
143PyArg_ParseTupleAndKeywords() currently requires.) But should we do
144this? It's additional work and not required for any of the other
145parts.
146
147
148Project: making classes use the new machinery
149*********************************************
150
151Tasks:
152
153Try to get rid of all code in classobject.c by deferring to the new
154mechanisms. How far can we get without breaking backwards
155compatibility? This is underspecified because I haven't thought much
156about it yet. Can we lose the use of PyInstance_Check() everywhere?
157I would hope so!
158
159
160Project: backwards compatibility
161********************************
162
163Tasks:
164
165Make sure all code checks the proper tp_flags bit before accessing
166type object fields.
167
168Identify areas of incompatibility with Python 2.1. Design solutions.
169Implement and test.
170
171Some specific areas: a fair amount of code probably depends on
172specific types having __members__ and/or __methods__ attributes.
173These are currently not present (conformant to PEP 252, which proposes
174to drop them) but we may have to add them back. This can be done in a
175generic way with not too much effort. Tim adds: Perhaps that dir(object)
176rarely returns anything but [] now is a consequence of this. I'm very
177used to doing, e.g., dir([]) or dir("") in an interactive shell to jog my
178memory; also one of the reasons test_generators failed.
179
180Another area: going all the way with classes and instances means that
181type(x) == types.InstanceType won't work any more to detect instances.
182Should there be a mode where this still works? Maybe this should be
183the default mode, with a warning, and an explicit way to get the new
184way to work? (Instead of a __future__ statement, I'm thinking of a
185module global __metaclass__ which would provide the default metaclass
186for baseless class statements.)
187
188
189Project: testing
190****************
191
192Tasks:
193
194Identify new functionality that needs testing. Conceive unit tests
195for all new functionality. Conceive stress tests for critical
196features. Run the tests. Fix bugs. Repeat until satisfied.
197
198Note: this may interact with the branch integration task.
199
200
Tim Petersf9803012001-08-02 22:06:35 +0000201Project: integration with main branch *** This is done - tim ***
Tim Peters6d6c1a32001-08-02 04:15:00 +0000202*************************************
203
204Tasks:
205
206Merge changes in the HEAD branch into the descr-branch. Then merge
207the descr-branch back into the HEAD branch.
208
209The longer we wait, the more effort this will be -- the descr-branch
210forked off quite a long time ago, and there are changes everywhere in
211the HEAD branch (e.g. the dict object has been radically rewritten).
212
213On the other hand, if we do this too early, we'll have to do it again
214later.
215
216Note from Tim: We should never again wait until literally 100s of files
217are out of synch. I don't care how often I need to do this, provided only
218that it's a tractable task each time. Once per week sounds like a good
219idea. As is, even the trunk change to rangeobject.c created more than its
220proper share of merge headaches, because it confused all the other reasons
221include file merges were getting conflicts (the more changes there are, the
222worse diff does; indeed, I came up with the ndiff algorithm in the 80s
223precisely because the source-control diff program Cray used at the time
224produced minimal but *senseless* diffs, thus creating artificial conflicts;
225paying unbounded attention to context does a much better job of putting
226changes where they make semantic sense too; but we're stuck with Unix diff
227here, and it isn't robust in this sense; if we don't keep its job simple,
228it will make my job hell).
229
230Done:
231To undo or rename before final merge: Modules/spam.c has worked its
232way into the branch Unix and Windows builds (pythoncore.dsp and
233PC/config.c); also imported by test_descr.py. How about renaming to
Tim Petersf9803012001-08-02 22:06:35 +0000234xxsubtype.c (whatever) now? *** this is done - tim ***
Tim Peters6d6c1a32001-08-02 04:15:00 +0000235
236
237Project: performance tuning
238***************************
239
240Tasks:
241
242Pick or create a general performance benchmark for Python. Benchmark
243the new system vs. the old system. Profile the new system. Improve
244hotspots. Repeat until satisfied.
245
246Note: this may interact with the branch integration task.
247
248
249Project: documentation
250**********************
251
252Tasks:
253
254Update PEP 252 (descriptors). Describe more of the prototype
255implementation
256
257Update PEP 253 (subtyping). Complicated architectural wrangling with
258metaclasses. There is an interaction between implementation and
259description.
260
261Write PEP 254 (unification of classes). This should discuss what
262changes for ordinary classes, and how we can make it more b/w
263compatible.
264
265Other documentation. There needs to be user documentation,
266eventually.
267
268
269Project: community interaction
270******************************
271
272Tasks:
273
274Once the PEPs are written, solicit community feedback, and formulate
275responses to the feedback. Give the community enough time to think
276over this complicated proposal. Provide the community with a
277prototype implementation to test. Try to do this *before* casting
278everything in stone!
279
280MERGE BEGIN ****************************************************************
281Merge details (this section is Tim's scratchpad, but should help a lot if
282he dies of frustration while wrestling with CVS <0.9 wink>).
283----------------------------------------------------------------------------
2842001-08-01 Merging descr-branch back into trunk.
285
286Tagged trunk about 22:05:
287 cvs tag date2001-08-01 python
288
289Merged trunk delta into branch:
290 cvs -q -z3 up -j date2001-07-30 -j date2001-08-01 descr
291
292No conflicts (! first time ever!) ... but problems with pythoncore.dsp.
293Resolved.
294
295Rebuilt from scratch; ran all tests; checked into branch about 22:40.
296
Tim Petersf9803012001-08-02 22:06:35 +0000297Merged descr-branch back into trunk (SEE BELOW -- this specific way of
298doing it was a bad idea):
299
Tim Peters6d6c1a32001-08-02 04:15:00 +0000300 cvs -q -z3 up -j descr-branch python
301
30234 conflicts. Hmm! OK, looks like every file in the project with an
303embedded RCS Id is "a conflict". Others make no sense, e.g., a dozen
304conflicts in dictobject.c, sometimes enclosing identical(!) blobs of
305source code. And CVS remains utterly baffled by Python type object decls.
Tim Petersf9803012001-08-02 22:06:35 +0000306Every line of ceval.c's generator code is in conflict blocks ... OK,
Tim Peters6d6c1a32001-08-02 04:15:00 +0000307there's no pattern or sense here, I'll just deal with it.
308
Tim Petersf9803012001-08-02 22:06:35 +0000309Conflicts resolved; rebuilt from scratch; test_weakref fails. Didn't find
310an obvious reason and it was late, so committed it anyway. Tagged the
311trunk then with tag:
312
313 after-descr-branch-merge
314
315Tracked the test_weakref failure to a botched conflict resolution in
316classobject.c; checked in a fix.
317
318LATER: The merge should have been done via:
319
320 upd -j date2001-08-01 -j descr-branch python
321
322instead. This would have caused only one conflict, a baffler in
323bltinmodule.c. It would have avoided the classobject.c error I made.
324Luckily, except for that one, we got to the same place in the end anyway,
325apart from a few curious tabs-vs-spaces differences.
Tim Peters6d6c1a32001-08-02 04:15:00 +0000326----------------------------------------------------------------------------
3272001-07-30
328
329Doing this again while the expat and Windows installer changes are still
330fresh on my mind.
331
332Tagged trunk about 23:50 EDT on the 29th:
333 cvs tag date2001-07-30 python
334
335Merged trunk delta into branch:
336
337 cvs -q -z3 up -j date2001-07-28 -j date2001-07-30 descr
338
3392 conflicts, resolved.
340----------------------------------------------------------------------------
3412001-07-28
342
343Tagged trunk about 00:31 EDT:
344 cvs tag date2001-07-28 python
345
346Merged trunk delta into branch:
347 cvs -q -z3 up -j date2001-07-21 -j date2001-07-28 descr
348
3494 conflicts, all RCS Ids. Resolved.
350----------------------------------------------------------------------------
3512001-07-21
352
353Tagged trunk about 01:00 EDT:
354 cvs tag date2001-07-21 python
355
356Merged trunk delta into branch:
357 cvs -q -z3 up -j date2001-07-17b -j date2001-07-21 descr
358
3594 conflicts, mostly RCS Id thingies. Resolved.
360
361Legit failure in new test_repr, because repr.py dispatches on the exact
362string returned by type(x). type(1L) and type('s') differ in descr-branch
363now, and repr.py didn't realize that, falling back to the "unknown type"
364case for longs and strings. Repaired descr-branch repr.py.
365----------------------------------------------------------------------------
3662001-07-19
367
368Removed the r22a1-branch tag (see next entry). Turns out Guido did add a
369r22a1 tag, so the r22a1-branch tag served no point anymore.
370----------------------------------------------------------------------------
3712001-07-18 2.2a1 releaase
372
373Immediately after the merge just below, I tagged descr-branch via
374
375 cvs tag r22a1-branch descr
376
377Guido may or may not want to add another tag here (? maybe he wants to do
378some more Unix fiddling first).
379----------------------------------------------------------------------------
3802001-07-17 building 2.2a1 release, from descr-branch
381
382Tagged trunk about 22:00 EDT, like so:
383 cvs tag date2001-07-17b python
384
385Merged trunk delta into branch via:
386 cvs -q -z3 up -j date2001-07-17a -j date2001-07-17b descr
387----------------------------------------------------------------------------
3882001-07-17
389
390Tagged trunk about 00:05 EDT, like so:
391 cvs tag date2001-07-17a python
392
393Merged trunk delta into branch via:
394 cvs -q -z3 up -j date2001-07-16 -j date2001-07-17a descr
395----------------------------------------------------------------------------
3962001-07-16
397
398Tagged trunk about 15:20 EDT, like so:
399 cvs tag date2001-07-16 python
400
401Guido then added all the other dist/ directories to descr-branch from that
402trunk tag.
403
404Tim then merged trunk delta into the branch via:
405 cvs -q -z3 up -j date2001-07-15 -j date2001-07-16 descr
406----------------------------------------------------------------------------
4072001-07-15
408
409Tagged trunk about 15:44 EDT, like so:
410 cvs tag date2001-07-15 python
411
412Merged trunk delta into branch via:
413 cvs -q -z3 up -j date2001-07-13 -j date2001-07-15 descr
414
415Four files with conflicts, all artificial RCS Id & Revision thingies.
416Resolved and committed.
417----------------------------------------------------------------------------
4182001-07-13
419
420Tagged trunk about 22:13 EDT, like so:
421 cvs tag date2001-07-13 python
422
423Merged trunk delta into branch via:
424 cvs -q -z3 up -j date2001-07-06 -j date2001-07-13 descr
425
426Six(!) files with conflicts, mostly related to NeilS's generator gc patches.
427Unsure why, but CVS seems always to think there are conflicts whenever a
428line in a type object decl gets changed, and the conflict marking seems
429maximally confused in these cases. Anyway, since I reviewed those patches
430on the trunk, good thing I'm merging them, and darned glad it's still fresh
431on my mind.
432
433Resolved the conflicts, and committed the changes in a few hours total.
434----------------------------------------------------------------------------
4352001-07-07
436
437Merge of trunk tag date2001-07-06 into descr-branch, via
438 cvs -q -z3 up -j date2001-07-06 mergedescr
439was committed on 2001-07-07.
440
441Merge issues:
442
443(all resolved -- GvR)
444----------------------------------------------------------------------------
4452001-07-06
446
447Tagged trunk a bit after midnight, like so:
448
449C:\Code>cvs tag date2001-07-06 python
450cvs server: Tagging python
451cvs server: Tagging python/dist
452cvs server: Tagging python/dist/src
453T python/dist/src/.cvsignore
454T python/dist/src/LICENSE
455T python/dist/src/Makefile.pre.in
456T python/dist/src/README
457... [& about 3000 lines more] ...
458
459This is the first trunk snapshot to be merged into the descr-branch.
460Gave it a date instead of a goofy name because there's going to be more
461than one of these, and at least it's obvious which of two ISO dates comes
462earlier. These tags should go away after all merging is complete.
463MERGE END ******************************************************************