Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'cpython': 0.05; 'element': 0.07; '(aka': 0.09; 'explanation': 0.09; 'keys,': 0.09; 'python:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'references.': 0.09; 'used.': 0.09; 'python': 0.11; 'stored': 0.12; '"small"': 0.16; 'big,': 0.16; 'elements,': 0.16; 'false)': 0.16; 'fiction.': 0.16; 'field).': 0.16; 'ian.': 0.16; 'internally': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'variables,': 0.16; 'elements': 0.16; 'language': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'value.': 0.19; 'fit': 0.20; 'feb': 0.22; 'memory': 0.22; 'header:User-Agent:1': 0.23; 'entries': 0.24; 'example.': 0.24; 'received:comcast.net': 0.24; 'references': 0.26; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'header :In-Reply-To:1': 0.27; 'subject:list': 0.30; 'container': 0.31; 'slot': 0.31; 'values.': 0.31; 'another': 0.32; 'fri,': 0.33; 'agree': 0.35; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; '14,': 0.36; 'entry': 0.36; 'too': 0.37; 'two': 0.37; 'list': 0.37; 'to:addr:python-list': 0.38; 'list,': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'received:org': 0.40; 'called': 0.40; 'ian': 0.60; 'such': 0.63; 'different': 0.65; 'management': 0.65; 'between': 0.67; 'details,': 0.68; 'covers': 0.68; 'pictures': 0.72; 'nonsense.': 0.84; 'picture': 0.97 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ned Batchelder Subject: Re: Explanation of list reference Date: Fri, 14 Feb 2014 15:45:23 -0500 References: <13208de8-0f85-4e60-b059-dc087c8fda41@googlegroups.com> <917ede6d-db7c-4a8c-8203-27677283776b@googlegroups.com> <871tz5piy0.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: c-50-133-228-126.hsd1.ma.comcast.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392410739 news.xs4all.nl 2930 [2001:888:2000:d::a6]:36379 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66325 On 2/14/14 3:17 PM, Ian Kelly wrote: > On Fri, Feb 14, 2014 at 12:56 PM, Marko Rauhamaa wrote: >> There are two fundamentally different kinds of values in Python: "small" >> values and "big" values. A variable can only hold a small value. A list >> element can only hold a small value. A dictionary entry can only hold a >> small value. The same is true for an object member (aka field). >> >> So we have four kinds of (memory) slots: variables, list elements, >> dictionary entries and fields. Any slot can only hold a small value. >> >> The small values include numbers, booleans (True or False) and >> references. All other values are big, too big to fit in a slot. They >> have to be stored in a "vault" big enough to hold them. This vault is >> called the heap. Big values cannot be stored in slots directly; instead, >> references to big values are used. > > This is nonsense. Python the language makes no such distinction > between "big" and "small" values. *All* objects in CPython are stored > internally on the heap. Other implementations may use different > memory management schemes. > Marko, I have to agree with Ian. While I really like the picture you drew, the distinction between big and small values is pure fiction. CPython does not store ints directly in list elements, for example. All names are references to values. All list elements (and dictionary values, dictionary keys, set elements, etc) are references to values. A value can be another container like a list, or it can be something "simple" like an int. This covers all the details, including pictures like Marko's, but with an explanation why we draw the ints inside the boxes: http://nedbatchelder.com/text/names.html -- Ned Batchelder, http://nedbatchelder.com