Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Dennis Lee Bieber Newsgroups: comp.lang.python Subject: Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?) Date: Thu, 24 Mar 2016 21:02:29 -0400 Organization: IISS Elusive Unicorn Lines: 42 Message-ID: References: <56f02196$0$1588$c3e8da3$5496439d@news.astraweb.com> <56f42d9f$0$1618$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de YnF27HgSrVACkCZIyUxBVwfutLCXdpVd8bOKqLVU2zPA== 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; 'static': 0.03; 'assignment': 0.07; 'exit': 0.07; 'loop.': 0.09; 'message- id:@4ax.com': 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; 'subject:which': 0.09; 'python': 0.10; 'programs.': 0.11; 'exception': 0.13; 'thu,': 0.15; 'value.': 0.15; '2016': 0.16; '>that': 0.16; 'called,': 0.16; 'conditional': 0.16; 'count.': 0.16; 'iterable': 0.16; 'iterator': 0.16; 'iterator:': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:?)': 0.16; "wouldn't": 0.16; 'integer': 0.18; 'url:home': 0.18; 'explicit': 0.22; 'pass': 0.22; 'header:X-Complaints-To:1': 0.26; 'function': 0.28; 'catching': 0.29; 'knows': 0.32; 'says': 0.32; 'maybe': 0.33; 'similar': 0.33; 'changing': 0.34; 'done': 0.35; 'c++': 0.35; 'something': 0.35; 'should': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'expect': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'anything': 0.38; 'end': 0.39; 'data': 0.39; 'sure': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'behavior': 0.61; 'subject:The': 0.61; 'provide': 0.61; 'more': 0.63; 'mar': 0.65; 'special': 0.73; '>function': 0.84; 'c++:': 0.84; 'dennis': 0.91; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: adsl-108-73-117-233.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:105670 On Thu, 24 Mar 2016 19:54:54 +0000, BartC declaimed the following: > >(I use a dedicated repeat-N-times loop that needs no explicit loop >variable, only an internal integer count. I use a special 'proc' form of >function with no return value. And I use static functions so the >byte-code knows the function being called, and knows it returns no value >that needs to be popped.) Well, that sure wouldn't support a Python for-loop, which works with indefinite iterable objects... Python for-loops end when the iterator says it has no more data to provide to the loop. Python does not do a "counted" loop. Changing this behavior would break oh so many existing programs. Think of the Python for-loop as being something similar to a C while-loop with an assignment in the conditional Python: for itm in iterator: pass C: while (Null != (itm = iterator()); Though actually that should maybe be done with C++ exception catching and a for-loop with no exit conditional... Something like [I just pulled down the C++ book -- don't expect anything that compiles] C++: try { for (itm = iterator(); ; itm = iterator()) ; } catch (end_iteration) ; -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/