Copy constructors

Guido van Rossum guido at python.org
Mon Aug 13 22:31:23 EDT 2001


> From: Guido van Rossum <guido at python.org>
> > I don't know how familiar you are with Python's C-level internals. If
> > you are, you'll appreciate the problem if I took a list object and
> > changed its type pointer to the dictionary type -- the instance
> > lay-out of a dictionary is different, and all the methods would be
> > using the list data as if it were dictionary data.  Recipe for
> > disaster.  Likewise, changing a featureless object into a list or dict
> > would at the very least require growing the size of the instance; this
> > would require a realloc(), which may move the object in memory.  But
> > if there are other references to the object, these would all have to
> > be updated.  Python's run-time architecture just doesn't support that.

"gzeljko" <gzeljko at sezampro.yu> writes:

> Is pointer indirection here to expensive ?

Yes, since it would require totally rewriting all existing Python
object types -- both built-in and 3rd party extension modules -- and
that's exactly what I am trying to avoid.

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-list mailing list