Phillip J. Eby wrote:

> I meant that just changing its class is a mutation, and since immutables 
> can be shared or cached, that could lead to problems.  So I do think 
> it's a reasonable implementation limit to disallow changing the 
> __class__ of an immutable.

That's a fair point.

Although I was actually thinking recently of a use
case for changing the class of a tuple, inside a
Pyrex module for database access. The idea was that
the user would be able to supply a custom subclass
of tuple for returning the records. To avoid extra
copying of the data, I was going to create a normal
uninitialised tuple, stuff the data into it, and then
change its class to the user-supplied one.

But seeing as all this would be happening in Pyrex
where the normal restrictions don't apply anyway, I
suppose it wouldn't matter if user code wasn't allowed
to do this.

Greg
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to