Weakrefs to classes that derive from str
Ron Garret
rNOSPAMon at flownet.com
Wed Mar 30 20:45:37 EST 2005
In article <-4KdnSsFwtp0RtffRVn-oA at powergate.ca>,
Peter Hansen <peter at engcorp.com> wrote:
> Ron Garret wrote:
> >>>>foo(int)
> >>>>foo(float)
> >>>>foo(dict)
> >>>>foo(list)
> >>>>foo(str)
> > TypeError: cannot create weak reference to 'C' object
> >
> >>>>foo(tuple)
> > TypeError: cannot create weak reference to 'C' object
> >
> >>>>foo(long)
> > TypeError: cannot create weak reference to 'C' object
> >
> > Ah, it appears that non-immediate immutable types don't support
> > weakrefs. Hm...
>
> I see the same results you do, and yet I don't understand
> the comment. Can you please explain what "immediate"
> means in this context?
"Immediate" means a data type that will fit entirely in a machine
register, and therefore doesn't need to actually be stored in memory.
Ints and floats are the only two immediate types in Python. They are
immutable, but you can still create weakrefs to classes that derive from
them.
rg
More information about the Python-list
mailing list