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