[Python-Dev] Assignment to class of module? (Autoloading? (Making Queue.Queue easier to use)) (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Fri Oct 14 08:50:29 CEST 2005
- Previous message: [Python-Dev] Assignment to __class__ of module? (Autoloading? (Making Queue.Queue easier to use))
- Next message: [Python-Dev] Extending tuple unpacking
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] Assignment to __class__ of module? (Autoloading? (Making Queue.Queue easier to use))
- Next message: [Python-Dev] Extending tuple unpacking
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]