[Python-Dev] Py_TPFLAGS_HEAPTYPE too overloaded

Joshua Haberman joshua at reverberate.org
Mon Jul 27 10:14:21 CEST 2009


Greg Ewing <greg.ewing <at> canterbury.ac.nz> writes:
> Joshua Haberman wrote:
> > This is not as bad as having someone
> > set __class__ on one of my instances, or set attributes on my type, etc.
> 
> Is there any real need to prevent someone from doing
> those things?

My ultimate goal is to make my types as much like regular built-in types
as possible.  Python as a language has chosen to "lock down" built-in
objects, even going so far as to specifically check for the "Carlo Verre
hack."  I defer to those decisions to answer the question "is there any
real need to prevent someone from doing these things?"  If it's
important for the built-in types, why should it be less important for
mine?

I don't want my type to be a second-class citizen just because I happen
to be dynamically allocating it.

If I were writing this extension for a language like Ruby, for which it is
convention that built-in classes are "open," then I wouldn't mind allowing
these things.  I'm just trying to make my extension as idiomatic and "native"
as possible.

Josh



More information about the Python-Dev mailing list