From: Samuele P. <ped...@st...> - 2005-03-03 22:52:03
|
Brian Zimmer wrote: > Samuele, > > I have a couple of questions about how we should handle this transition > period for new-style classes. > > I cannot pass the full test_descrtut for list because it subclasses from > PySequence which is an old-style class (it has an classDictInit and no > typeSetup). Because of this, some methods (__iter__, __nonzero__) which > exist in the classDictInit call are exposed in the dict for the list > instance. > > Until all subclasses of PySequence are converted I don't want to remove > the classDictInit method but I also don't want it called for instances > of subclasses with typeSetup methods. It looks like I can reasonably do > this in PyType.fillFromClass but I'm wondering if it's worth the > effort. Should I just wait until the subclasses are done and then > switch it over to a new-style class? > PySequence should not be visible as a base class of list from Python. list.__bases__ should be (object,) A type_base_class directive should do that. OTOH what we likely want is a way to instead of having some list_* method have corresponding seq_* methods in PySequence that can be reused from its subclasses typeSetups, I'm working adding the expressivity to specify this to the code generator. > Also, I was looking at making all the builtin methods in __builtin__ be > instances of PyBuiltinFunction. Does this sound reasonable? yes > I have a > script which will parse __built__ and generated the appropriate > PyBuiltinFunction instances. Right now they are mixture of > .BuiltinFunctions and ReflectedFunctions, do we care about the > distinction? In CPython, they are the same type. > > Which brings me to another question. Should BuiltinMethodType in types > be a PyBuiltinFunction or continue to be a PyMethod? yes, PyBuiltinFunction is meant to be much more similar to Python types.BultinFunctionType == types.BuiltinMethodType == <type 'builtin_function_or_method'> ideally I would like if we were able to deprecate PyBuiltinFunctionSet. > > I also looked into implementing __slots__. How far should we take the > full slots approach in Jython? Should we go all out of the space > savings or just make them 'feel' like CPython objects with __slots__ in > that they can't grow an attribute? my plan was to have a PyObject[] array in the derived classes for the purpose of slots. It would be null if there are no slots. Notice that the precise semantics for slots vs having a dictionary are a bit tricky, for example the slot name __dict__ is special cased >>> class D(object): ... __slots__ = ('__dict__',) ... >>> d=D() >>> d.a=3 etc. Samuele. |