Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.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; 'string': 0.09; 'alain': 0.09; 'implemented.': 0.09; 'indexes': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:while': 0.09; 'python': 0.11; 'jan': 0.12; "'from": 0.16; 'dict': 0.16; 'fallback': 0.16; 'fallback.': 0.16; 'hint': 0.16; 'mandate': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:recursion': 0.16; 'index': 0.16; 'language': 0.16; 'wrote:': 0.18; 'module': 0.19; 'meant': 0.20; 'import': 0.22; 'header:User-Agent:1': 0.23; 'integer': 0.24; 'necessary.': 0.24; 'switched': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'array': 0.29; 'code': 0.31; 'easier': 0.31; '3.x': 0.31; 'keys': 0.31; 'mod': 0.31; 'writes:': 0.31; 'another': 0.32; 'could': 0.34; 'but': 0.35; 'words,': 0.36; 'mapping': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'either': 0.39; 'received:org': 0.40; 'how': 0.40; 'received:173': 0.61; 'name': 0.63; 'such': 0.63; 'become': 0.64; 'needing': 0.65; 'detail.': 0.68; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Tail recursion to while iteration in 2 easy steps Date: Mon, 07 Oct 2013 16:42:40 -0400 References: <87had0axxy.fsf@dpt-info.u-strasbg.fr> <524C80B6.3010204@unistra.fr> <87li292wnt.fsf@dpt-info.u-strasbg.fr> <878uy52ea0.fsf@dpt-info.u-strasbg.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0 In-Reply-To: <878uy52ea0.fsf@dpt-info.u-strasbg.fr> 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381178576 news.xs4all.nl 15922 [2001:888:2000:d::a6]:46377 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56327 On 10/7/2013 1:15 PM, Alain Ketterlin wrote: > Terry Reedy writes: >> 3. Python does not mandate how namespaces are implemented. CPython >> uses both dicts and, for function local namespaces, internal C arrays. >> So 'names' in code can become either string keys for dicts or integer >> indexes for arrays. > > Well, yes, but that's an implementation detail, no? That is why I switched from 'Python' to 'CPython'. But I note the following: in 2.x, 'from mod import *' in a function meant that the compile time mapping of name to index could not be used and that a fallback to dict was necessary. So another implementation might take the easier path and always use a dict for function locals. In 3.x, such import are limited to module scope so that functions can always use an array and indexes for function locals. So other implementations can take the hint and do the same without needing a dict fallback. In other words, 3.x changed the language to facilitate the implementation detail. -- Terry Jan Reedy