Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!feeder.news-service.com!news2.euro.net!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; 'subject:Python': 0.04; 'cpython': 0.07; 'interpreter': 0.07; 'terry': 0.07; 'python': 0.07; 'namespace': 0.09; 'oh,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'programmer': 0.11; 'am,': 0.14; 'wrote:': 0.14; 'arrays.': 0.16; 'detail:': 0.16; 'function)': 0.16; 'namespace,': 0.16; 'reedy': 0.16; 'fixed.': 0.16; 'functions,': 0.19; 'mapping': 0.19; 'stick': 0.19; 'jan': 0.22; 'header:In-Reply-To:1': 0.22; 'subject:data': 0.26; '(in': 0.27; 'object': 0.27; 'function': 0.27; 'subject:?': 0.29; 'depends': 0.29; 'does': 0.31; 'import': 0.32; 'to:addr:python-list': 0.32; 'another': 0.32; 'asking': 0.32; 'words,': 0.33; 'bit': 0.33; 'array': 0.33; 'header:X-Complaints-To:1': 0.34; 'actually': 0.34; 'header:User-Agent:1': 0.35; 'subject:What': 0.35; 'subject:use': 0.35; 'usually': 0.36; 'think': 0.36; 'table': 0.37; 'should': 0.37; 'steven': 0.38; 'strings': 0.38; 'received:org': 0.38; 'though': 0.38; 'set': 0.39; 'to:addr:python.org': 0.39; 'header :Mime-Version:1': 0.39; 'how': 0.39; 'add': 0.39; "it's": 0.40; 'header:Received:5': 0.40; 'best': 0.60; 'details': 0.64; 'subject:other': 0.84; 'ask,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: What other languages use the same data model as Python? Date: Mon, 09 May 2011 16:23:21 -0400 References: <4dbd1dbf$0$29991$c3e8da3$5496439d@news.astraweb.com> <77f64071-b288-404c-8280-b2c61ba77f06@n10g2000yqf.googlegroups.com> <4dc12fb4$0$29991$c3e8da3$5496439d@news.astraweb.com> <7q1898-f3l.ln1@svn.schaathun.net> <9fd898-0el.ln1@svn.schaathun.net> <92f70aF9pqU1@mid.individual.net> <92kh9cFgdcU1@mid.individual.net> <4dc5fd42$0$29991$c3e8da3$5496439d@news.astraweb.com> <92os6dF5jbU1@mid.individual.net> <4dc7fa2f$0$29991$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: rain.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 In-Reply-To: <4dc7fa2f$0$29991$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 25 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1304972612 news.xs4all.nl 41117 [::ffff:82.94.164.166]:37998 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5023 On 5/9/2011 10:29 AM, Steven D'Aprano wrote: > > If people then ask, how does the interpreter know the names?, I can add > more detail: names are actually strings in a namespace, which is usually > nothing more than a dict. Oh, and inside functions, it's a bit more > complicated still. And so on. Which is why I think it best to stick with 'A namespace is a many-to-one mapping (in other words, a function) of names to objects'. Any programmer should understand the abstractions 'mapping' and 'function'. Asking how the interpreter finds the object associated with a name amounts to asking how to do tabular lookup. Well, we basically know, though the details depends on the implementation of the table (mapping). An interpreter can *implement* namespaces various ways. One is to objectify names and namespaces as strings and dicts. If the set of names in a namespace is fixed, another way is to objectify names and namespaces as ints and arrays. Python prohibits 'from x import *' within functions precisely to keep the set of local namespace names fixed. Therefore, CPython can and does always use C ints and array for function local namespaces. -- Terry Jan Reedy