[Python-3000] A better way to initialize PyTypeObject
Guido van Rossum
guido at python.org
Tue Nov 28 16:39:11 CET 2006
Some comments:
- I'm all for trying something new here; the existing approach is
definitely aged.
- Fredrik's solution makes one call per registered method. (I don't
know if the patch he refers to follows that model.) That seems a fair
amount of code for an average type -- I'm wondering if it's too early
to worry about code bloat (I don't think the speed is going to
matter).
- Talin's solution seems to require the definition of an awful lot of
new constants -- one per slot. And a lot of special-casing in the type
initialization code to handle them because there are so many different
signatures.
- Both solutions proposed require rewriting *all* type initialization.
This is likely to require a tool that can do 99% of the work
automatically (or else extension writers will truly hate us). But then
maybe we could write a tool instead that can automatically rewrite a
type struct declaration to follow the new lay-out. Since almost all
type declarations are cloned from the examples in early Python, they
are very regular -- basically it's an optional case, a function name
or zero, and a comment with the member name.
- Can't we require a C99 compiler and use C99 struct initialization?
Then the table lines could look like
tp_new = Noddy_new,
tp_init = Noddy_init,
This probably means the conversion tool would be even simpler (a
couple of lines of sed would do). It has my vote if C99 is available
on Windows (GCC covers all other platforms -- vendors that don't have
a C99 compiler yet lose, it's 2006 now for X sake).
--Guido
On 11/28/06, Fredrik Lundh <fredrik at pythonware.com> wrote:
> Talin wrote:
>
> > Has anyone proposed the notion of getting away from C-style initializer
> > lists, at least for the case of PyTypeObject?
>
> yes, and it was mentioned in the python-dev summaries that were mailed
> out a couple of days ago:
>
> http://effbot.org/zone/idea-register-type.htm
>
> Larry Hastings has prepared a patch for this; check the patch tracker or
> the python-dev archives for details.
>
> </F>
>
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list