[BangPypers] python id function

Anand Balachandran Pillai abpillai at gmail.com
Thu Jan 7 09:50:33 CET 2010


On Thu, Jan 7, 2010 at 2:16 PM, Anand Balachandran Pillai <
abpillai at gmail.com> wrote:

>
>
>  Python caches immutable objects - which is why they are immutable
>

 Should correct myself here - this means that *all* immutables are
cached. I did not mean that - what I meant that *only* immutables
are cached. So read it as "Python caches some immutable objects"
 and skip the "which is..." part. :)


>  and saves memory if u reference the same immutable in many
>  places. So small integers, empty tuples and such are actually
>  cached in Python runtime, so you keep getting back the same object
>  and hence the same id.
>
> A few examples (as above).
>
>
>


More information about the BangPypers mailing list