blob: d0530b4b19e6889717cf436c70c2bdb044aeddd0 [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
92More -- I'm sure new issues will crop up as we go.
93
94
95Project: loose ends and follow-through
96**************************************
97
98Tasks:
99
100Make more (most?) built-in types act as their own factory functions.
101
102Make more (most?) built-in types subtypable -- with or without
103overridable allocation. *** This includes descriptors! It should be
104possible to write descriptors in Python, so metaclasses can do clever
105things with them. ***
106
107Exceptions should be types. This changes the rules, since now almost
108anything can be raised (as maybe it should). Or should we strive for
109enforcement of the convention that all exceptions should be derived
110from Exception? String exceptions will be another hassle, to be
111deprecated and eventually ruled out.
112
113Standardize a module containing names for all built-in types, and
114standardize on names. E.g. should the official name of the string
115type be 'str', 'string', or 'StringType'?
116
117Create a hierarchy of types, so that e.g. int and long are both
118subtypes of an abstract base type integer, which is itself a subtype
119of number, etc. A lot of thinking can go into this!
120
121*** NEW TASK??? ***
122Implement "signature" objects. These are alluded to in PEP 252 but
123not yet specified. Supposedly they provide an easily usable API to
124find out about function/method arguments. Building these for Python
125functions is simple. Building these for built-in functions will
126require a change to the PyMethodDef structure, so that a type can
127provide signature information for its C methods. (This would also
128help in supporting keyword arguments for C methods with less work than
129PyArg_ParseTupleAndKeywords() currently requires.) But should we do
130this? It's additional work and not required for any of the other
131parts.
132
133
134Project: making classes use the new machinery
135*********************************************
136
137Tasks:
138
139Try to get rid of all code in classobject.c by deferring to the new
140mechanisms. How far can we get without breaking backwards
141compatibility? This is underspecified because I haven't thought much
142about it yet. Can we lose the use of PyInstance_Check() everywhere?
143I would hope so!
144
145
146Project: backwards compatibility
147********************************
148
149Tasks:
150
151Make sure all code checks the proper tp_flags bit before accessing
152type object fields.
153
154Identify areas of incompatibility with Python 2.1. Design solutions.
155Implement and test.
156
157Some specific areas: a fair amount of code probably depends on
158specific types having __members__ and/or __methods__ attributes.
159These are currently not present (conformant to PEP 252, which proposes
160to drop them) but we may have to add them back. This can be done in a
161generic way with not too much effort. Tim adds: Perhaps that dir(object)
162rarely returns anything but [] now is a consequence of this. I'm very
163used to doing, e.g., dir([]) or dir("") in an interactive shell to jog my
164memory; also one of the reasons test_generators failed.
165
166Another area: going all the way with classes and instances means that
167type(x) == types.InstanceType won't work any more to detect instances.
168Should there be a mode where this still works? Maybe this should be
169the default mode, with a warning, and an explicit way to get the new
170way to work? (Instead of a __future__ statement, I'm thinking of a
171module global __metaclass__ which would provide the default metaclass
172for baseless class statements.)
173
174
175Project: testing
176****************
177
178Tasks:
179
180Identify new functionality that needs testing. Conceive unit tests
181for all new functionality. Conceive stress tests for critical
182features. Run the tests. Fix bugs. Repeat until satisfied.
183
184Note: this may interact with the branch integration task.
185
186
Tim Petersf9803012001-08-02 22:06:35 +0000187Project: integration with main branch *** This is done - tim ***
Tim Peters6d6c1a32001-08-02 04:15:00 +0000188*************************************
189
190Tasks:
191
192Merge changes in the HEAD branch into the descr-branch. Then merge
193the descr-branch back into the HEAD branch.
194
195The longer we wait, the more effort this will be -- the descr-branch
196forked off quite a long time ago, and there are changes everywhere in
197the HEAD branch (e.g. the dict object has been radically rewritten).
198
199On the other hand, if we do this too early, we'll have to do it again
200later.
201
202Note from Tim: We should never again wait until literally 100s of files
203are out of synch. I don't care how often I need to do this, provided only
204that it's a tractable task each time. Once per week sounds like a good
205idea. As is, even the trunk change to rangeobject.c created more than its
206proper share of merge headaches, because it confused all the other reasons
207include file merges were getting conflicts (the more changes there are, the
208worse diff does; indeed, I came up with the ndiff algorithm in the 80s
209precisely because the source-control diff program Cray used at the time
210produced minimal but *senseless* diffs, thus creating artificial conflicts;
211paying unbounded attention to context does a much better job of putting
212changes where they make semantic sense too; but we're stuck with Unix diff
213here, and it isn't robust in this sense; if we don't keep its job simple,
214it will make my job hell).
215
216Done:
217To undo or rename before final merge: Modules/spam.c has worked its
218way into the branch Unix and Windows builds (pythoncore.dsp and
219PC/config.c); also imported by test_descr.py. How about renaming to
Tim Petersf9803012001-08-02 22:06:35 +0000220xxsubtype.c (whatever) now? *** this is done - tim ***
Tim Peters6d6c1a32001-08-02 04:15:00 +0000221
222
223Project: performance tuning
224***************************
225
226Tasks:
227
228Pick or create a general performance benchmark for Python. Benchmark
229the new system vs. the old system. Profile the new system. Improve
230hotspots. Repeat until satisfied.
231
232Note: this may interact with the branch integration task.
233
234
235Project: documentation
236**********************
237
238Tasks:
239
240Update PEP 252 (descriptors). Describe more of the prototype
241implementation
242
243Update PEP 253 (subtyping). Complicated architectural wrangling with
244metaclasses. There is an interaction between implementation and
245description.
246
247Write PEP 254 (unification of classes). This should discuss what
248changes for ordinary classes, and how we can make it more b/w
249compatible.
250
251Other documentation. There needs to be user documentation,
252eventually.
253
254
255Project: community interaction
256******************************
257
258Tasks:
259
260Once the PEPs are written, solicit community feedback, and formulate
261responses to the feedback. Give the community enough time to think
262over this complicated proposal. Provide the community with a
263prototype implementation to test. Try to do this *before* casting
264everything in stone!
265
266MERGE BEGIN ****************************************************************
267Merge details (this section is Tim's scratchpad, but should help a lot if
268he dies of frustration while wrestling with CVS <0.9 wink>).
269----------------------------------------------------------------------------
2702001-08-01 Merging descr-branch back into trunk.
271
272Tagged trunk about 22:05:
273 cvs tag date2001-08-01 python
274
275Merged trunk delta into branch:
276 cvs -q -z3 up -j date2001-07-30 -j date2001-08-01 descr
277
278No conflicts (! first time ever!) ... but problems with pythoncore.dsp.
279Resolved.
280
281Rebuilt from scratch; ran all tests; checked into branch about 22:40.
282
Tim Petersf9803012001-08-02 22:06:35 +0000283Merged descr-branch back into trunk (SEE BELOW -- this specific way of
284doing it was a bad idea):
285
Tim Peters6d6c1a32001-08-02 04:15:00 +0000286 cvs -q -z3 up -j descr-branch python
287
28834 conflicts. Hmm! OK, looks like every file in the project with an
289embedded RCS Id is "a conflict". Others make no sense, e.g., a dozen
290conflicts in dictobject.c, sometimes enclosing identical(!) blobs of
291source code. And CVS remains utterly baffled by Python type object decls.
Tim Petersf9803012001-08-02 22:06:35 +0000292Every line of ceval.c's generator code is in conflict blocks ... OK,
Tim Peters6d6c1a32001-08-02 04:15:00 +0000293there's no pattern or sense here, I'll just deal with it.
294
Tim Petersf9803012001-08-02 22:06:35 +0000295Conflicts resolved; rebuilt from scratch; test_weakref fails. Didn't find
296an obvious reason and it was late, so committed it anyway. Tagged the
297trunk then with tag:
298
299 after-descr-branch-merge
300
301Tracked the test_weakref failure to a botched conflict resolution in
302classobject.c; checked in a fix.
303
304LATER: The merge should have been done via:
305
306 upd -j date2001-08-01 -j descr-branch python
307
308instead. This would have caused only one conflict, a baffler in
309bltinmodule.c. It would have avoided the classobject.c error I made.
310Luckily, except for that one, we got to the same place in the end anyway,
311apart from a few curious tabs-vs-spaces differences.
Tim Peters6d6c1a32001-08-02 04:15:00 +0000312----------------------------------------------------------------------------
3132001-07-30
314
315Doing this again while the expat and Windows installer changes are still
316fresh on my mind.
317
318Tagged trunk about 23:50 EDT on the 29th:
319 cvs tag date2001-07-30 python
320
321Merged trunk delta into branch:
322
323 cvs -q -z3 up -j date2001-07-28 -j date2001-07-30 descr
324
3252 conflicts, resolved.
326----------------------------------------------------------------------------
3272001-07-28
328
329Tagged trunk about 00:31 EDT:
330 cvs tag date2001-07-28 python
331
332Merged trunk delta into branch:
333 cvs -q -z3 up -j date2001-07-21 -j date2001-07-28 descr
334
3354 conflicts, all RCS Ids. Resolved.
336----------------------------------------------------------------------------
3372001-07-21
338
339Tagged trunk about 01:00 EDT:
340 cvs tag date2001-07-21 python
341
342Merged trunk delta into branch:
343 cvs -q -z3 up -j date2001-07-17b -j date2001-07-21 descr
344
3454 conflicts, mostly RCS Id thingies. Resolved.
346
347Legit failure in new test_repr, because repr.py dispatches on the exact
348string returned by type(x). type(1L) and type('s') differ in descr-branch
349now, and repr.py didn't realize that, falling back to the "unknown type"
350case for longs and strings. Repaired descr-branch repr.py.
351----------------------------------------------------------------------------
3522001-07-19
353
354Removed the r22a1-branch tag (see next entry). Turns out Guido did add a
355r22a1 tag, so the r22a1-branch tag served no point anymore.
356----------------------------------------------------------------------------
3572001-07-18 2.2a1 releaase
358
359Immediately after the merge just below, I tagged descr-branch via
360
361 cvs tag r22a1-branch descr
362
363Guido may or may not want to add another tag here (? maybe he wants to do
364some more Unix fiddling first).
365----------------------------------------------------------------------------
3662001-07-17 building 2.2a1 release, from descr-branch
367
368Tagged trunk about 22:00 EDT, like so:
369 cvs tag date2001-07-17b python
370
371Merged trunk delta into branch via:
372 cvs -q -z3 up -j date2001-07-17a -j date2001-07-17b descr
373----------------------------------------------------------------------------
3742001-07-17
375
376Tagged trunk about 00:05 EDT, like so:
377 cvs tag date2001-07-17a python
378
379Merged trunk delta into branch via:
380 cvs -q -z3 up -j date2001-07-16 -j date2001-07-17a descr
381----------------------------------------------------------------------------
3822001-07-16
383
384Tagged trunk about 15:20 EDT, like so:
385 cvs tag date2001-07-16 python
386
387Guido then added all the other dist/ directories to descr-branch from that
388trunk tag.
389
390Tim then merged trunk delta into the branch via:
391 cvs -q -z3 up -j date2001-07-15 -j date2001-07-16 descr
392----------------------------------------------------------------------------
3932001-07-15
394
395Tagged trunk about 15:44 EDT, like so:
396 cvs tag date2001-07-15 python
397
398Merged trunk delta into branch via:
399 cvs -q -z3 up -j date2001-07-13 -j date2001-07-15 descr
400
401Four files with conflicts, all artificial RCS Id & Revision thingies.
402Resolved and committed.
403----------------------------------------------------------------------------
4042001-07-13
405
406Tagged trunk about 22:13 EDT, like so:
407 cvs tag date2001-07-13 python
408
409Merged trunk delta into branch via:
410 cvs -q -z3 up -j date2001-07-06 -j date2001-07-13 descr
411
412Six(!) files with conflicts, mostly related to NeilS's generator gc patches.
413Unsure why, but CVS seems always to think there are conflicts whenever a
414line in a type object decl gets changed, and the conflict marking seems
415maximally confused in these cases. Anyway, since I reviewed those patches
416on the trunk, good thing I'm merging them, and darned glad it's still fresh
417on my mind.
418
419Resolved the conflicts, and committed the changes in a few hours total.
420----------------------------------------------------------------------------
4212001-07-07
422
423Merge of trunk tag date2001-07-06 into descr-branch, via
424 cvs -q -z3 up -j date2001-07-06 mergedescr
425was committed on 2001-07-07.
426
427Merge issues:
428
429(all resolved -- GvR)
430----------------------------------------------------------------------------
4312001-07-06
432
433Tagged trunk a bit after midnight, like so:
434
435C:\Code>cvs tag date2001-07-06 python
436cvs server: Tagging python
437cvs server: Tagging python/dist
438cvs server: Tagging python/dist/src
439T python/dist/src/.cvsignore
440T python/dist/src/LICENSE
441T python/dist/src/Makefile.pre.in
442T python/dist/src/README
443... [& about 3000 lines more] ...
444
445This is the first trunk snapshot to be merged into the descr-branch.
446Gave it a date instead of a goofy name because there's going to be more
447than one of these, and at least it's obvious which of two ISO dates comes
448earlier. These tags should go away after all merging is complete.
449MERGE END ******************************************************************