On 12/12/06, Jim Jewett <[EMAIL PROTECTED]> wrote:
On 12/8/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > I've been thinking about this too, and I think it's reasonable to let > the metaclass provide the dict to be used as locals.
I do wonder about this though: will it require a particular type (like a dict)? The current code uses fast locals, as a class is essentially a function (and practically, too; just look at the generated bytecode.) We'd either need a new mechanism to build classes that was separate from functions, or we'd have to slow down the entire function execution case to handler the 'custom locals'. I'm sure people will want it for normal functions, too, then (debuggers, for instance.) The slowdown might be reduced to near-insignificant by providing a fast type in C that can proxy or be subclassed for specific behaviour, but falls back to the same sort of vector indexing as fast locals. I know, I know, premature optimization and all, but this is a rather fundamental part of Python's speed. (Strangely enough, when I tried this out, a with- block that set the
module-global __metaclass__ seemed to work for classic classes but not for new-style classes. I didn't investigate beyond that. Code below the .sig for those who care.)
That's not strange; only classic classes look at the global __metaclass__ :) The lookup goes: class dict (setting __metaclass__ in the class suite), metaclass of parent classes (first one not classic, provided there is no conflict when inheriting from multiple classes), __metaclass__ module global. -- Thomas Wouters <[EMAIL PROTECTED]> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
_______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com