On Tue, Mar 17, 2009 at 6:14 PM, grocery_stocker <cdal...@gmail.com> wrote:
> Given the following.... > > [example of cached numbers] > > > It seems like id(list[<some value>]) == id(<some value>). However, I > can't find anything in the python documentation that talks about it. > Did I perhaps overlook something? You didn't find anything because there's nothing to find. The fact that "7 is 7" is an implementation detail- CPython caches small numbers (I believe <256) and some strings to boost performance. This isn't necessarily true of Python in general. Python 2.6.1 (r261:67515, Dec 9 2008, 14:03:29) [GCC 4.0.1 (Apple Inc. build 5484)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> a = 7 >>> b = 7 >>> id(a) 8405312 >>> id(b) 8405312 >>> a is b True IronPython 1.1 (1.1) on .NET 2.0.50727.1433 Copyright (c) Microsoft Corporation. All rights reserved. >>> a = 7 >>> b = 7 >>> id(a) 43L >>> id(b) 44L >>>a is b False > -- > http://mail.python.org/mailman/listinfo/python-list >
-- http://mail.python.org/mailman/listinfo/python-list