Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #56520

Re: Tail recursion to while iteration in 2 easy steps

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.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 <charleshixsn@earthlink.net>
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; 'python,': 0.02; 'example:': 0.03; 'algorithm': 0.04; 'source,': 0.04; 'output': 0.05; '(except': 0.07; 'compiler': 0.07; 'encouraging': 0.07; 'remaining': 0.07; 'x86': 0.07; '"source': 0.09; 'atom': 0.09; 'definition,': 0.09; 'difference,': 0.09; 'high-level': 0.09; 'measure': 0.09; 'oh,': 0.09; 'repeated': 0.09; 'stating': 0.09; 'subject:while': 0.09; 'used.': 0.09; 'python': 0.11; 'language,': 0.12; 'translation': 0.12; 'wrote': 0.14; 'language.': 0.14; 'buggy': 0.16; 'charles': 0.16; 'command,': 0.16; 'compiler.': 0.16; 'construct.': 0.16; 'constructs': 0.16; 'degree.': 0.16; 'emit': 0.16; 'exists,': 0.16; 'experiments': 0.16; 'hardware.': 0.16; 'janssen': 0.16; 'key)': 0.16; 'lexical': 0.16; 'lisp': 0.16; 'measurement': 0.16; 'merely': 0.16; 'message- id:@earthlink.net': 0.16; 'motorola': 0.16; 'operation:': 0.16; 'otherwise:': 0.16; 'processor,': 0.16; 'reasonably': 0.16; 'received:dsl.mindspring.com': 0.16; 'reversed': 0.16; 'specifying': 0.16; 'subject:recursion': 0.16; 'such,': 0.16; 'targeting': 0.16; 'valid.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'discussion': 0.18; 'obviously': 0.18; 'written': 0.21; 'seems': 0.21; 'machine': 0.22; '>>>': 0.22; 'programming': 0.22; 'putting': 0.22; 'saying': 0.22; 'header :User-Agent:1': 0.23; 'either.': 0.24; 'integer': 0.24; 'rid': 0.24; 'specify': 0.24; 'techniques,': 0.24; 'mon,': 0.24; 'sort': 0.25; 'source': 0.25; 'changes,': 0.26; 'define': 0.26; 'equivalent': 0.26; 'long,': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'generally': 0.29; 'operations,': 0.30; "i'm": 0.30; '(which': 0.31; 'included': 0.31; 'code': 0.31; 'software,': 0.31; '(usually': 0.31; '-0700,': 0.31; '>>>>': 0.31; 'analytical': 0.31; 'assert': 0.31; "d'aprano": 0.31; 'description,': 0.31; 'directly,': 0.31; 'layer': 0.31; 'steven': 0.31; 'probably': 0.32; 'languages': 0.32; 'supposed': 0.32; 'run': 0.32; 'implemented': 0.33; 'device': 0.34; 'could': 0.34; 'problem': 0.35; 'something': 0.35; 'case,': 0.35; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'really': 0.36; 'believed': 0.36; 'machine.': 0.36; 'reality': 0.36; 'science.': 0.36; 'more': 0.64; 'different': 0.65; 'afraid': 0.65; 'talking': 0.65; 'virus': 0.65; 'here': 0.66; 'between': 0.67; 'person,': 0.68; 'physics': 0.68; 'physical': 0.72; 'russian': 0.74; 'forth': 0.81; 'compiling': 0.84; 'cosmic': 0.84; 'fact.': 0.84; 'guaranteed.': 0.84; 'mistaken': 0.84; 'one*': 0.84; 'single,': 0.84; 'standing': 0.84; 'take,': 0.84; 'underneath': 0.84; 'defeat': 0.91; 'good,': 0.91; 'light,': 0.91; 'notion': 0.91; 'procedural': 0.91; 'same,': 0.91; 'besides,': 0.93; 'many,': 0.93; 'technique': 0.93; '2013': 0.98
Date Wed, 09 Oct 2013 15:45:05 -0700
From Charles Hixson <charleshixsn@earthlink.net>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130922 Icedove/17.0.9
MIME-Version 1.0
To python-list@python.org
Subject Re: Tail recursion to while iteration in 2 easy steps
References <mailman.571.1380663065.18130.python-list@python.org> <87had0axxy.fsf@dpt-info.u-strasbg.fr> <CAMjeLr9KPf=Z4pJoQtU8LXiT686dABg-fpNoWYb9reEPRSsYjA@mail.gmail.com> <524C80B6.3010204@unistra.fr> <mailman.651.1380747919.18130.python-list@python.org> <87li292wnt.fsf@dpt-info.u-strasbg.fr> <mailman.732.1380925974.18130.python-list@python.org> <878uy52ea0.fsf@dpt-info.u-strasbg.fr> <5252F610.9040403@rece.vub.ac.be> <mailman.821.1381188514.18130.python-list@python.org> <525348d7$0$29984$c3e8da3$5496439d@news.astraweb.com> <mailman.823.1381192919.18130.python-list@python.org> <52536f96$0$29984$c3e8da3$5496439d@news.astraweb.com> <mailman.824.1381202841.18130.python-list@python.org> <5253cee4$0$29976$c3e8da3$5496439d@news.astraweb.com>
In-Reply-To <5253cee4$0$29976$c3e8da3$5496439d@news.astraweb.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.911.1381358766.18130.python-list@python.org> (permalink)
Lines 129
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1381358766 news.xs4all.nl 15872 [2001:888:2000:d::a6]:58202
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:56520

Show key headers only | View raw


On 10/08/2013 02:22 AM, Steven D'Aprano wrote:
> On Mon, 07 Oct 2013 20:27:13 -0700, Mark Janssen wrote:
>
>>>>> But even putting that aside, even if somebody wrote such a
>>>>> description, it would be reductionism gone mad. What possible light
>>>>> on the problem would be shined by a long, long list of machine code
>>>>> operations, even if written using assembly mnemonics?
>>>> Only that you've got a consistent, stable (and therefore,
>>>> formalizable) translation from your language to the machine.
>>> You are mistaken to think that there is a single, one-to-one, mapping
>>> between high-level code and machine code.
>> It's not mistaken.
> I'm afraid it is. Reality trumps your theory. gcc, clang, Microsoft
> Visual Studio, and all the many, many other C compilers do not generate
> identical machine code even when targeting the same hardware. This is a
> fact. It's not even the case that there is One True Way to implement a
> particular program on a given hardware device and compilers merely are
> buggy for doing something else. There are often different ways to
> implement it which are equally good, the only difference being personal
> preference.
>
>
>> Given a stable and formalized language definition,
>> there should only be continued optimization of the lexical and
>> procedural constructs into better machine code.
> Better than what? "Continued" optimization? When you say "lexical and
> procedural constructs", do you mean "source code"?
>
>
>> In the case of an
>> "interpreted" language like Python (which I'll define as a language
>> which includes a layer of indirection between the user and the machine,
> Irrelevant. In the case of Python, there is a machine. The fact that it
> is a VM rather than a physical machine is irrelevant. A machine is a
> machine -- we could be talking about a Lisp Machine, a Forth Machine, a
> x86 processor, an Motorola 68000, an Atom processor, one of those old
> Russian mainframes that used three-state trits instead of two-state bits,
> or even Babbage's Analytical Engine.
>
> Besides, most modern CPUs don't execute machine code directly, they run
> the machine code in a virtual machine implemented in hardware. So the
> difference between Python and x86 machine code is just a matter of degree.
>
>
>
>> encouraging the nice benefits of interactivity), such optimization isn't
>> really apropos, because it's not the purpose of python to be optimal to
>> the machine as much as "optimal to the programmer".  In any case, while
>> such optimization can continue over time, they generally create new
>> compiler releases to indicate such changes.  The one-to-one mapping is
>> held by the compiler.
>>
>> Such determinism *defines* the machine, otherwise you might as well get
>> rid of the notion of computer *science*.  All else is error, akin to
>> cosmic rays or magic.  Unless the source code changes, all else
>> remaining equal, the machine code is supposed to be the same, no matter
>> how many times it is compiled.
> That is akin to saying that there is *only one* way to measure the speed
> of light (say), standing in exactly the same place, using exactly the
> same equipment, using precisely the same measurement techniques, and that
> if we allow alternative methods for measuring the speed of light, physics
> is no longer a science.
>
>
>>> [Only if you use the exact source, compiler, switches, etc]] will the
>>> output be the same.
>>> And even that is not guaranteed.
>> Oh, and what would cause such non-determinism?
> The compiler-writer, of course. A compiler is software, and is written by
> a person, who can program it to do anything the writer wants. If the
> writer wants the compiler to be non-deterministic, it can be.
>
> Some viruses use a similar technique to try to avoid virus scanners. They
> encrypt the payload, which is functionally equivalent to randomizing it
> (except it can be reversed if you have the key) so as to defeat virus
> scanners.
>
> A more whimsical example: perhaps a mischievous compiler writer included
> something like this in her compiler:
>
>
> when compiling integer multiplication, INT * INT:
>    if today is Tuesday:
>      emit machine code that does multiplication using repeated addition
>    otherwise:
>      emit machine code that does multiplication using ADD and SHIFT
>
>
> Both implementations of multiplication are perfectly valid. There may be
> a performance difference, or there may not be. Since no sensible
> programming language is going to specify the *detailed* machine code
> implementation of its high-level operations, such a mischievous compiler
> would still be valid.
>
>
>>> Take, for example, the single high-level operation:
>>>
>>> sort(alist)
>>>
>>> What machine code will be executed? Obviously that will depend on the
>>> sort algorithm used. There are *dozens*. Here are just a few:
>> Well, since you didn't specify your programming language, you're then
>> merely stating an English construct.
> What difference does it make? But if it will make you feel better, I'm
> specifying Hypertalk. You've probably never heard of it, but regardless,
> it exists, and it has a sort command, and the high-level language does
> not specify which of many sort algorithms is to be used.
>
>
>
>> As such, there can be no single
>> mapping from English into the machine, which is why there are so many
>> different languages and experiments that map your [English] concepts
>> into source code.
> And there is no single mapping from <INSERT **ANY** HIGH-LEVEL
> PROGRAMMING LANGUAGE HERE> source code to machine code either.
I would assert that Python is not inherently a virtual machine 
language.  Originally, IIRC, it was believed that LISP couldn't be 
compiled.  Also, you could implement that virtual machine as a hardware 
machine.  (Also, of course, on modern hardware assembly language is run 
on a virtual machine, implemented by an underneath microcode layer.)

You can reasonably say that an implementation of Python is done in terms 
of a virtual machine.  (Usually I don't bother about this kind of 
nit-pick, but in this discussion it seems apropos.)

-- 
Charles Hixson

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Tail recursion to while iteration in 2 easy steps Terry Reedy <tjreedy@udel.edu> - 2013-10-01 17:30 -0400
  Re: Tail recursion to while iteration in 2 easy steps rusi <rustompmody@gmail.com> - 2013-10-01 22:16 -0700
    Re: Tail recursion to while iteration in 2 easy steps Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2013-10-02 10:23 +0200
      Re: Tail recursion to while iteration in 2 easy steps rusi <rustompmody@gmail.com> - 2013-10-02 06:29 -0700
    Re: Tail recursion to while iteration in 2 easy steps Ravi Sahni <ganeshsahni07@gmail.com> - 2013-10-03 22:57 +0530
      Re: Tail recursion to while iteration in 2 easy steps rusi <rustompmody@gmail.com> - 2013-10-04 03:52 -0700
  Re: Tail recursion to while iteration in 2 easy steps Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2013-10-02 10:17 +0200
    Re: Tail recursion to while iteration in 2 easy steps Mark Janssen <dreamingforward@gmail.com> - 2013-10-02 11:59 -0700
    Re: Tail recursion to while iteration in 2 easy steps Mark Janssen <dreamingforward@gmail.com> - 2013-10-02 14:05 -0700
      Re: Tail recursion to while iteration in 2 easy steps Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2013-10-04 11:49 +0200
        Re: Tail recursion to while iteration in 2 easy steps Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-04 10:51 +0000
        Re: Tail recursion to while iteration in 2 easy steps Terry Reedy <tjreedy@udel.edu> - 2013-10-04 18:32 -0400
          Re: Tail recursion to while iteration in 2 easy steps Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2013-10-07 19:15 +0200
            Re: Tail recursion to while iteration in 2 easy steps Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-07 19:57 +0200
              Re: Tail recursion to while iteration in 2 easy steps Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2013-10-08 10:56 +0200
                Re: Tail recursion to while iteration in 2 easy steps Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-10-08 12:49 +0300
            Re: Tail recursion to while iteration in 2 easy steps Terry Reedy <tjreedy@udel.edu> - 2013-10-07 16:42 -0400
            Re: Tail recursion to while iteration in 2 easy steps random832@fastmail.us - 2013-10-07 17:19 -0400
              Re: Tail recursion to while iteration in 2 easy steps Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2013-10-08 10:41 +0200
            Re: Tail recursion to while iteration in 2 easy steps MRAB <python@mrabarnett.plus.com> - 2013-10-07 22:39 +0100
            Re: Tail recursion to while iteration in 2 easy steps Piet van Oostrum <piet@vanoostrum.org> - 2013-10-07 18:03 -0400
            Re: Tail recursion to while iteration in 2 easy steps Mark Janssen <dreamingforward@gmail.com> - 2013-10-07 15:47 -0700
              Re: Tail recursion to while iteration in 2 easy steps Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-07 23:50 +0000
                Re: Tail recursion to while iteration in 2 easy steps Mark Janssen <dreamingforward@gmail.com> - 2013-10-07 17:24 -0700
                Formal-ity and the Church-Turing thesis rusi <rustompmody@gmail.com> - 2013-10-07 20:17 -0700
                Re: Formal-ity and the Church-Turing thesis Ravi Sahni <ganeshsahni07@gmail.com> - 2013-10-08 10:46 +0530
                Re: Formal-ity and the Church-Turing thesis rusi <rustompmody@gmail.com> - 2013-10-07 22:44 -0700
                Re: Formal-ity and the Church-Turing thesis Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-08 07:43 +0100
                Re: Formal-ity and the Church-Turing thesis Ravi Sahni <ganeshsahni07@gmail.com> - 2013-10-08 18:31 +0530
                Re: Formal-ity and the Church-Turing thesis rusi <rustompmody@gmail.com> - 2013-10-08 06:33 -0700
                Re: Formal-ity and the Church-Turing thesis Steven D'Aprano <steve@pearwood.info> - 2013-10-08 07:50 +0000
                Re: Formal-ity and the Church-Turing thesis Ravi Sahni <ganeshsahni07@gmail.com> - 2013-10-08 18:16 +0530
                Re: Formal-ity and the Church-Turing thesis Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-08 13:11 +0000
                Re: Formal-ity and the Church-Turing thesis Robert Day <robertkday@gmail.com> - 2013-10-08 14:25 +0100
                Re: Formal-ity and the Church-Turing thesis Chris Angelico <rosuav@gmail.com> - 2013-10-09 08:36 +1100
                Re: Formal-ity and the Church-Turing thesis Mark Janssen <dreamingforward@gmail.com> - 2013-10-07 22:19 -0700
                Re: Formal-ity and the Church-Turing thesis rusi <rustompmody@gmail.com> - 2013-10-07 23:01 -0700
                Re: Formal-ity and the Church-Turing thesis Mark Janssen <dreamingforward@gmail.com> - 2013-10-08 10:39 -0700
                Re: Tail recursion to while iteration in 2 easy steps Mark Janssen <dreamingforward@gmail.com> - 2013-10-07 17:16 -0700
                Re: Tail recursion to while iteration in 2 easy steps Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-08 02:36 +0000
                Re: Tail recursion to while iteration in 2 easy steps Mark Janssen <dreamingforward@gmail.com> - 2013-10-07 20:27 -0700
                Re: Tail recursion to while iteration in 2 easy steps Steven D'Aprano <steve@pearwood.info> - 2013-10-08 09:22 +0000
                Re: Tail recursion to while iteration in 2 easy steps Charles Hixson <charleshixsn@earthlink.net> - 2013-10-09 15:45 -0700
                Re: Tail recursion to while iteration in 2 easy steps Piet van Oostrum <piet@vanoostrum.org> - 2013-10-07 22:46 -0400
                Re: Tail recursion to while iteration in 2 easy steps Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-10-08 10:25 +0300
                Re: Tail recursion to while iteration in 2 easy steps Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-08 11:18 +0200
              Re: Tail recursion to while iteration in 2 easy steps Piet van Oostrum <piet@vanoostrum.org> - 2013-10-07 22:45 -0400
                Re: Tail recursion to while iteration in 2 easy steps Mark Janssen <dreamingforward@gmail.com> - 2013-10-07 20:34 -0700
    Re: Tail recursion to while iteration in 2 easy steps Terry Reedy <tjreedy@udel.edu> - 2013-10-02 18:17 -0400
      Re: Tail recursion to while iteration in 2 easy steps Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-03 01:24 +0000
        Re: Tail recursion to while iteration in 2 easy steps Dave Angel <davea@davea.name> - 2013-10-03 01:39 +0000
        Re: Tail recursion to while iteration in 2 easy steps MRAB <python@mrabarnett.plus.com> - 2013-10-03 02:46 +0100
          Re: Tail recursion to while iteration in 2 easy steps Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-03 02:34 +0000
            Re: Tail recursion to while iteration in 2 easy steps Chris Angelico <rosuav@gmail.com> - 2013-10-03 14:14 +1000
            Re: Tail recursion to while iteration in 2 easy steps random832@fastmail.us - 2013-10-03 10:16 -0400
            Re: Tail recursion to while iteration in 2 easy steps Terry Reedy <tjreedy@udel.edu> - 2013-10-03 15:04 -0400
        Re: Tail recursion to while iteration in 2 easy steps Terry Reedy <tjreedy@udel.edu> - 2013-10-02 22:41 -0400
          Re: Tail recursion to while iteration in 2 easy steps Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-04 01:30 +0000
        Re: Tail recursion to while iteration in 2 easy steps Terry Reedy <tjreedy@udel.edu> - 2013-10-02 23:06 -0400
        Re: Tail recursion to while iteration in 2 easy steps random832@fastmail.us - 2013-10-03 10:14 -0400
        Literal syntax for frozenset, frozendict (was: Tail recursion to while iteration in 2 easy steps) Ben Finney <ben+python@benfinney.id.au> - 2013-10-04 10:18 +1000
        Re: Literal syntax for frozenset, frozendict Ethan Furman <ethan@stoneleaf.us> - 2013-10-03 18:31 -0700
    Re: Tail recursion to while iteration in 2 easy steps Duncan Booth <duncan.booth@invalid.invalid> - 2013-10-03 14:52 +0000
      Re: Tail recursion to while iteration in 2 easy steps Neil Cerutti <neilc@norwich.edu> - 2013-10-03 16:03 +0000
        Re: Tail recursion to while iteration in 2 easy steps Duncan Booth <duncan.booth@invalid.invalid> - 2013-10-04 10:16 +0000
          Re: Tail recursion to while iteration in 2 easy steps Ian Kelly <ian.g.kelly@gmail.com> - 2013-10-04 04:41 -0600
          Re: Tail recursion to while iteration in 2 easy steps Ian Kelly <ian.g.kelly@gmail.com> - 2013-10-04 04:46 -0600
            Re: Tail recursion to while iteration in 2 easy steps Duncan Booth <duncan.booth@invalid.invalid> - 2013-10-04 11:16 +0000
          Re: Tail recursion to while iteration in 2 easy steps Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-10-04 14:11 +0300
          Re: Tail recursion to while iteration in 2 easy steps Terry Reedy <tjreedy@udel.edu> - 2013-10-04 17:14 -0400
          Re: Tail recursion to while iteration in 2 easy steps Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-05 09:39 +0200
          Re: Tail recursion to while iteration in 2 easy steps random832@fastmail.us - 2013-10-07 17:27 -0400
            Re: Tail recursion to while iteration in 2 easy steps Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-10-08 10:11 +0300
          Re: Tail recursion to while iteration in 2 easy steps Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-08 11:43 +0200

csiph-web