[Python-3000] A better way to initialize PyTypeObject

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Nov 29 01:04:10 CET 2006


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
the valid special method names.

> You could go even further, and drop the "special" flag entirely, and 
> there's a compelling reason why you might want to do this: It means that 
> now the VM gets to decide what methods are special and what methods 
> aren't.

No, that would be a bad idea. It would mean, for
example, that *any* method called "next" would have
to be assumed to potentially be the next() method of
an iterator and forced to have the corresponding
signature.

(This is why I changed its name to __next__ in Pyrex.
I suppose the same solution could be used here, if you
were willing to accept the name that you put in the method
table not necessarily being the name you use from Python.)

  --
Greg


More information about the Python-3000 mailing list