<br><br><div class="gmail_quote">On Tue, Mar 17, 2009 at 6:14 PM, grocery_stocker <span dir="ltr"><<a href="mailto:cdalten@gmail.com">cdalten@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Given the following....<br>
<br>
[example of cached numbers]<br>
<br>
<br>
It seems like id(list[<some value>]) == id(<some value>). However, I<br>
can't find anything in the python documentation that talks about it.<br>
Did I perhaps overlook something?</blockquote><div><br>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. <br>
<br>Python 2.6.1 (r261:67515, Dec  9 2008, 14:03:29) <br>[GCC 4.0.1 (Apple Inc. build 5484)] on darwin<br>Type "help", "copyright", "credits" or "license" for more information.<br>>>> a = 7<br>
>>> b = 7<br>>>> id(a)<br>8405312<br>>>> id(b)<br>8405312<br>>>> a is b<br>True<br><br><br>IronPython 1.1 (1.1) on .NET 2.0.50727.1433<br>Copyright (c) Microsoft Corporation. All rights reserved.<br>
>>> a = 7<br>>>> b = 7<br>>>> id(a)<br>43L<br>>>> id(b)<br>44L<br>>>>a is b<br>False <br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>