blob: 1ab384ccea06af0e387d9321da8148eb9a7afe1f [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
187Project: integration with main branch
188*************************************
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
220xxsubtype.c (whatever) now?
221
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
283Merged descr-branch back into trunk:
284 cvs -q -z3 up -j descr-branch python
285
28634 conflicts. Hmm! OK, looks like every file in the project with an
287embedded RCS Id is "a conflict". Others make no sense, e.g., a dozen
288conflicts in dictobject.c, sometimes enclosing identical(!) blobs of
289source code. And CVS remains utterly baffled by Python type object decls.
290Every line of ceval.c's generator code si in conflict blocks ... OK,
291there's no pattern or sense here, I'll just deal with it.
292
293Conflicts resolved; rebuilt from scratch; test_weakref fails.
294----------------------------------------------------------------------------
2952001-07-30
296
297Doing this again while the expat and Windows installer changes are still
298fresh on my mind.
299
300Tagged trunk about 23:50 EDT on the 29th:
301 cvs tag date2001-07-30 python
302
303Merged trunk delta into branch:
304
305 cvs -q -z3 up -j date2001-07-28 -j date2001-07-30 descr
306
3072 conflicts, resolved.
308----------------------------------------------------------------------------
3092001-07-28
310
311Tagged trunk about 00:31 EDT:
312 cvs tag date2001-07-28 python
313
314Merged trunk delta into branch:
315 cvs -q -z3 up -j date2001-07-21 -j date2001-07-28 descr
316
3174 conflicts, all RCS Ids. Resolved.
318----------------------------------------------------------------------------
3192001-07-21
320
321Tagged trunk about 01:00 EDT:
322 cvs tag date2001-07-21 python
323
324Merged trunk delta into branch:
325 cvs -q -z3 up -j date2001-07-17b -j date2001-07-21 descr
326
3274 conflicts, mostly RCS Id thingies. Resolved.
328
329Legit failure in new test_repr, because repr.py dispatches on the exact
330string returned by type(x). type(1L) and type('s') differ in descr-branch
331now, and repr.py didn't realize that, falling back to the "unknown type"
332case for longs and strings. Repaired descr-branch repr.py.
333----------------------------------------------------------------------------
3342001-07-19
335
336Removed the r22a1-branch tag (see next entry). Turns out Guido did add a
337r22a1 tag, so the r22a1-branch tag served no point anymore.
338----------------------------------------------------------------------------
3392001-07-18 2.2a1 releaase
340
341Immediately after the merge just below, I tagged descr-branch via
342
343 cvs tag r22a1-branch descr
344
345Guido may or may not want to add another tag here (? maybe he wants to do
346some more Unix fiddling first).
347----------------------------------------------------------------------------
3482001-07-17 building 2.2a1 release, from descr-branch
349
350Tagged trunk about 22:00 EDT, like so:
351 cvs tag date2001-07-17b python
352
353Merged trunk delta into branch via:
354 cvs -q -z3 up -j date2001-07-17a -j date2001-07-17b descr
355----------------------------------------------------------------------------
3562001-07-17
357
358Tagged trunk about 00:05 EDT, like so:
359 cvs tag date2001-07-17a python
360
361Merged trunk delta into branch via:
362 cvs -q -z3 up -j date2001-07-16 -j date2001-07-17a descr
363----------------------------------------------------------------------------
3642001-07-16
365
366Tagged trunk about 15:20 EDT, like so:
367 cvs tag date2001-07-16 python
368
369Guido then added all the other dist/ directories to descr-branch from that
370trunk tag.
371
372Tim then merged trunk delta into the branch via:
373 cvs -q -z3 up -j date2001-07-15 -j date2001-07-16 descr
374----------------------------------------------------------------------------
3752001-07-15
376
377Tagged trunk about 15:44 EDT, like so:
378 cvs tag date2001-07-15 python
379
380Merged trunk delta into branch via:
381 cvs -q -z3 up -j date2001-07-13 -j date2001-07-15 descr
382
383Four files with conflicts, all artificial RCS Id & Revision thingies.
384Resolved and committed.
385----------------------------------------------------------------------------
3862001-07-13
387
388Tagged trunk about 22:13 EDT, like so:
389 cvs tag date2001-07-13 python
390
391Merged trunk delta into branch via:
392 cvs -q -z3 up -j date2001-07-06 -j date2001-07-13 descr
393
394Six(!) files with conflicts, mostly related to NeilS's generator gc patches.
395Unsure why, but CVS seems always to think there are conflicts whenever a
396line in a type object decl gets changed, and the conflict marking seems
397maximally confused in these cases. Anyway, since I reviewed those patches
398on the trunk, good thing I'm merging them, and darned glad it's still fresh
399on my mind.
400
401Resolved the conflicts, and committed the changes in a few hours total.
402----------------------------------------------------------------------------
4032001-07-07
404
405Merge of trunk tag date2001-07-06 into descr-branch, via
406 cvs -q -z3 up -j date2001-07-06 mergedescr
407was committed on 2001-07-07.
408
409Merge issues:
410
411(all resolved -- GvR)
412----------------------------------------------------------------------------
4132001-07-06
414
415Tagged trunk a bit after midnight, like so:
416
417C:\Code>cvs tag date2001-07-06 python
418cvs server: Tagging python
419cvs server: Tagging python/dist
420cvs server: Tagging python/dist/src
421T python/dist/src/.cvsignore
422T python/dist/src/LICENSE
423T python/dist/src/Makefile.pre.in
424T python/dist/src/README
425... [& about 3000 lines more] ...
426
427This is the first trunk snapshot to be merged into the descr-branch.
428Gave it a date instead of a goofy name because there's going to be more
429than one of these, and at least it's obvious which of two ISO dates comes
430earlier. These tags should go away after all merging is complete.
431MERGE END ******************************************************************