[Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Talin
More on the 'cruft removal' topic: I notice that a number of fields in PyTypeObject are deprecated; the question is, how to get rid of them without gratuitously breaking everything? Even if there's zero code out there that still uses tp_getattr instead of tp_getattro, you can't simply remove th

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Fredrik Lundh
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 Hast

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Greg Ewing
Talin wrote: > What you end up with is code that looks like this: > > PyTypeObject myType = { > PyObject_HEAD_INIT(NULL) > 0, > "myType", > sizeof(myInstance) > } > > void init() { > if (PyType_ReadyInit( &myType, myTypeMethods, myTypeData ) < 0) > return; > } If

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Talin
Greg Ewing wrote: > Talin wrote: > >> What you end up with is code that looks like this: >> >> PyTypeObject myType = { >> PyObject_HEAD_INIT(NULL) >> 0, >> "myType", >> sizeof(myInstance) >> } >> >> void init() { >> if (PyType_ReadyInit( &myType, myTypeMethods, myTypeData

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Guido van Rossum
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 t

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Fredrik Lundh
Guido van Rossum wrote: > - 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 goin

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Brent Benson
Guido van Rossum wrote: > - 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 m

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Jim Jewett
On 11/28/06, Talin <[EMAIL PROTECTED]> wrote: > For example, consider the case for tp_init and tp_new. ... you have > to put 37 initializer values before them, whether you use them or not. > Now, you still have the problem that 'tp_methods' itself is something > like the 28th field in the struct,

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Guido van Rossum
On 11/28/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > > - 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 ear

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Fredrik Lundh
Guido van Rossum wrote: >>> Can't we require a C99 compiler and use C99 struct initialization? >> that won't address the binary compatibility and optimization issues that >> are the main rationales for my proposal, though. > > Why not? This is the Py3k list -- there is no hope for binary > compat

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Talin
Fredrik Lundh wrote: > Guido van Rossum wrote: > >> - 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

Re: [Python-3000] Generic functions vs. OO

2006-11-28 Thread Bill Janssen
Guido van Rossum wrote: > I wonder if a bunch of well thought-out standard ABCs, applied to the > standard data types, and perhaps more support for setting __bases__, > wouldn't address most concerns. I think it would, but I don't know if we're going to get anywhere without getting more concrete.

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Guido van Rossum
On 11/28/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > >>> Can't we require a C99 compiler and use C99 struct initialization? > >> that won't address the binary compatibility and optimization issues that > >> are the main rationales for my proposal, though. > > > > Why

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Guido van Rossum
On 11/28/06, Talin <[EMAIL PROTECTED]> wrote: > Fredrik Lundh wrote: > > Guido van Rossum wrote: > > > >> - 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 won

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Talin
Guido van Rossum wrote: > Some comments: > > - 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. Actually, I was thinki

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Talin
Guido van Rossum wrote: > Some comments: > > - 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 thin

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Brett Cannon
On 11/28/06, Talin <[EMAIL PROTECTED]> wrote: Guido van Rossum wrote: > Some comments: > > - 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

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Guido van Rossum
On 11/28/06, Talin <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > Some comments: > > > > - 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

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Greg Ewing
Talin wrote: > The other drawback is that there's a greater chance of a misspelling, I don't think there is, really. It wouldn't be caught at compile time, but it would be caught very quickly at run time if you tried to initialise a type with a method flagged as "special" whose name wasn't one of

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Greg Ewing
Talin wrote: > It means that > now the VM gets to decide what methods are special and what methods > aren't. Further to that, the VM still gets to decide whether any given special method gets a type slot. But the SPECIAL flag is needed to say that you intend the method to be *used* as a special

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Ronald Oussoren
On 29 Nov 2006, at 1:10 AM, Greg Ewing wrote: BTW, another advantage of all this is that it provides a lot more flexibility in the overall approach to implementing the type object. For example, we might decide to move the type slots into a separate memory block, so that the type struct could

Re: [Python-3000] A better way to initialize PyTypeObject

2006-11-28 Thread Talin
Guido van Rossum wrote: > On 11/28/06, Talin <[EMAIL PROTECTED]> wrote: >> Guido van Rossum wrote: >> > Some comments: >> > >> > - 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