Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'talks': 0.03; 'subject:Python': 0.05; 'compiler': 0.05; 'guido': 0.05; 'c++,': 0.07; 'dynamically': 0.07; 'python': 0.09; '(without': 0.09; 'here?': 0.09; 'subject:Why': 0.09; 'subject:create': 0.09; 'language': 0.14; 'do,': 0.15; 'appreciated!': 0.16; 'c++.': 0.16; 'compilers': 0.16; "computer's": 0.16; 'googled': 0.16; 'hardware.': 0.16; 'subject: \n ': 0.16; 'wrote:': 0.17; 'creates': 0.18; 'saying': 0.18; 'memory': 0.18; 'feb': 0.19; 'variable': 0.20; 'written': 0.20; 'gcc': 0.22; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'cpu': 0.29; 'subject:like': 0.29; 'thinks': 0.29; "i'm": 0.29; 'code': 0.31; 'file': 0.32; 'could': 0.32; 'int': 0.33; 'handle': 0.33; 'to:addr :python-list': 0.33; 'languages': 0.33; "can't": 0.34; 'wrong': 0.34; 'follows:': 0.35; 'so,': 0.35; 'subject:?': 0.35; "won't": 0.35; 'there': 0.35; 'really': 0.36; 'but': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'possible': 0.37; 'does': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'takes': 0.39; 'build': 0.39; 'hello,': 0.39; 'where': 0.40; 'day,': 0.60; 'content- disposition:inline': 0.60; 'kind': 0.61; 'here:': 0.62; 'different': 0.63; 'love': 0.63; 'url:v': 0.68; 'url:youtube': 0.70; 'received:109': 0.74; 'url:watch': 0.74; '2013': 0.84; 'around,': 0.84; 'compiles': 0.84; 'received:195.238': 0.84; 'received:195.238.6': 0.84; 'received:belgacom.be': 0.84; 'received:isp.belgacom.be': 0.84; 'reasoning': 0.91; 'remember,': 0.93 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhoFAPLLL1FtgqK3/2dsb2JhbABFwjF8F3MPAQGCDgEBBTocMwsYCSUPBSWITgi0AY1FjxsWgklhA5ZAkGuBUoE3 Date: Thu, 28 Feb 2013 22:33:36 +0100 From: Jonas Geiregat To: python-list@python.org Subject: Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Mail-Followup-To: python-list@python.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362087285 news.xs4all.nl 6959 [2001:888:2000:d::a6]:57459 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40189 On do, feb 28, 2013 at 12:25:07pm -0800, kramer65 wrote: > Hello, > > I'm using Python for a while now and I love it. There is just one thing I cannot understand. There are compilers for languages like C and C++. why is it impossible to create a compiler that can compile Python code to machinecode? > > My reasoning is as follows: > When GCC compiles a program written in C++, it simply takes that code and decides what instructions that would mean for the computer's hardware. What does the CPU need to do, what does the memory need to remember, etc. etc. If you can create this machinecode from C++, then I would suspect that it should also be possible to do this (without a C-step in between) for programs written in Python. > > Where is my reasoning wrong here? Is that because Python is dynamically typed? Does machinecode always need to know whether a variable is an int or a float? And if so, can't you build a compiler which creates machinecode that can handle both ints and floats in case of doubt? Or is it actually possible to do, but so much work that nobody does it? > > I googled around, and I *think* it is because of the dynamic typing, but I really don't understand why this would be an issue.. > > Any insights on this would be highly appreciated! > Guido actually encourages people to try to build different compilers for python. He thinks it might, one day, be possible to have a compiler for python. But this could only be possible if there was some kind of global file based annotation saying you will not use some of the dynamic parts of python. Else it won't be possible to create a compiler for such a highly dynmaic language as python. You can view the key-note where he talks about this here: http://www.youtube.com/watch?v=EBRMq2Ioxsc Jonas.