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