Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; '(at': 0.04; 'syntax': 0.04; 'interpreter': 0.05; 'tree': 0.05; 'subject:Python': 0.06; 'bindings': 0.09; 'seemed': 0.09; 'subject:language': 0.09; 'psf': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; '(java': 0.16; 'advantage.': 0.16; 'ast': 0.16; 'bytecode': 0.16; 'c++.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'garbage': 0.16; 'it;': 0.16; 'language?': 0.16; 'subject: \n ': 0.16; 'sat,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'basically': 0.19; 'normally': 0.19; 'written': 0.21; 'code,': 0.22; 'programming': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'parse': 0.24; 'java': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'references': 0.26; 'this:': 0.26; 'pass': 0.26; 'least': 0.26; 'header:In-Reply- To:1': 0.27; 'wonder': 0.29; "doesn't": 0.30; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'program,': 0.31; 'code': 0.31; 'embed': 0.31; 'libraries': 0.31; 'file': 0.32; 'languages': 0.32; 'interface': 0.32; 'another': 0.32; 'text': 0.33; 'community': 0.33; 'maybe': 0.34; 'could': 0.34; 'knows': 0.35; 'etc': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'c++': 0.36; 'interface,': 0.36; 'library.': 0.36; 'object,': 0.36; 'done': 0.36; 'two': 0.37; 'easily': 0.37; 'handle': 0.38; 'pm,': 0.38; 'that,': 0.38; 'does': 0.39; 'how': 0.40; 'easy': 0.60; "google's": 0.60; 'liked': 0.60; 'most': 0.60; "you're": 0.61; 'back': 0.62; 'making': 0.63; 'between': 0.67; 'believe': 0.68; 'jobs': 0.68; 'gain': 0.79; 'forth': 0.81; 'subject:this': 0.83; 'gains': 0.84; 'canonical': 0.91; 'to:none': 0.92; 'suited': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=eTunPmM4eMGr4R47k5uObqgOTzXChxmjmHnTyYX5Epw=; b=wS39H4jJCAqvuza6t3qjCXIxMyj2L/cECKHthz9kh8Gd+ETxO0GDEoH/VpLpEQx2c+ LheVm0MHs0oGJqbUty/oq6dpzEjcs5tvOd8L8pClSv2zTiEhkz6Jc7YyDO/KikbkZUoF YWoQVPmHnQCzimAE1V/tW4LeWl4J5K1dgMEM85lvhJ50nx2pI+WlKbcTRMnXvuWix4vA LD6YYOLTV3jwYlUrf9ojTgaC3EOrYDTkWnxM+jJN/58lBeGpv/jCRDvsWQwBL0N0GWqc n6Bib43ZIiW/5UyCitCqwTb/+8Qd/ulyYvqjeuAZC8j9c5BvPsAWXgdnKQige1PNqdVn 9gLg== MIME-Version: 1.0 X-Received: by 10.68.110.165 with SMTP id ib5mr18953385pbb.61.1396673387429; Fri, 04 Apr 2014 21:49:47 -0700 (PDT) In-Reply-To: References: <9daf0806-02de-4447-964c-c8f8953c23e5@googlegroups.com> <5334c38e$0$29994$c3e8da3$5496439d@news.astraweb.com> <53364327$0$29994$c3e8da3$5496439d@news.astraweb.com> <53365F55.2040302@gmail.com> <533836c4$0$29994$c3e8da3$5496439d@news.astraweb.com> <533f47b5$0$29993$c3e8da3$5496439d@news.astraweb.com> Date: Sat, 5 Apr 2014 15:49:47 +1100 Subject: Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list) From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1396673391 news.xs4all.nl 2866 [2001:888:2000:d::a6]:41480 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69708 On Sat, Apr 5, 2014 at 3:31 PM, Mark H Harris wrote: > Its has always seemed to me that Java or C++ would be better suited to > creating python. I wonder will C always be the standard canonical PSF python > interpreter base language? Has the C python community considered making the > standard base language Java or C++ ? Java you know about (Jython); what's the advantage of C++ over C? A Python interpreter needs to do broadly this: 1) Parse a text file into an abstract syntax tree 2) Compile the AST into bytecode 3) Execute the bytecode: 3a) Manage object lifetimes and garbage collection 3b) Perform lower-level calls 3c) Efficiently handle namespaces etc Java has an advantage over C in that 3a can be done by the JVM. (At least, I believe that's how Jython does it; a Python object is backed by a Java object, and every Python object that references another Python object is backed by a corresponding reference to the corresponding Java object, so the JVM knows about all object lifetimes.) C++ doesn't have that, at least not normally (and I've never really liked most C++ garbage collectors - maybe there's a good one that I've not yet met), so all you'd really gain is 3b, in that you could conveniently pass jobs down to a lower-level C++ library. (Java also gains this advantage - or maybe disadvantage, as you can easily interface to other Java code but not so easily to C code.) Most programming languages make it easy to talk to C code, ergo most libraries are written for C interfaces, ergo most programming languages don't need C++. The only case I can think of is Google's V8 interpreter (ECMAScript), which uses C++ bindings to handle scoping; it's nice and easy as long as you embed V8 in a C++ program, and not so easy if you're going back and forth between the two languages; at that point, it basically reverts to a C-like interface, so there's no advantage. ChrisA