From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,b4a4dceda94869d2 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.204.129.8 with SMTP id m8mr617679bks.5.1320879586699; Wed, 09 Nov 2011 14:59:46 -0800 (PST) Path: l23ni11618bkv.0!nntp.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: "R. Tyler Croy" Newsgroups: comp.lang.ada Subject: Re: Iterators in Ada2012 Date: Wed, 9 Nov 2011 22:58:35 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <66dbca36-0248-458a-aff4-1176d6ce098b@m10g2000vbc.googlegroups.com> <4eb92ae0$0$6581$9b4e6d93@newsspool3.arcor-online.net> Mime-Version: 1.0 Injection-Date: Wed, 9 Nov 2011 22:58:35 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="E7dqto2st02wRDK911xc8A"; logging-data="14568"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+NnhSgoa/292V5ohvQM5UN" User-Agent: Pan/0.135 (Tomorrow I'll Wake Up and Scald Myself with Tea; GIT 30dc37b master) Cancel-Lock: sha1:nMiOjf5FUV7jBCtnfhsV5BCkn3g= Xref: news1.google.com comp.lang.ada:18891 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 2011-11-09T22:58:35+00:00 List-Id: On Wed, 09 Nov 2011 09:02:38 +0000, Simon Wright wrote: > "R. Tyler Croy" writes: > >> The reasons things like list comprehensions and generator expressions >> are recommended in Python is because they're faster in the CPython >> implementation of the language since they get to native C "faster" >> (with less interpretation and bytecode). > > I had no idea that list comprehensions were faster (I have no idea > whether Mac OS X's native Python is a CPython implementation!), I used > them because they are so expressive! (I'm aware this is off-topic for comp.lang.ada :)) Pretty much any time you're using Python, you're using the CPython implementation. The other options (Jython (java), IronPython (C#), PyPy (Python self-hosting)) are less used because they lag behind CPython or they have other issues. That said, yes, list comprehensions are certainly expressive! Having spend some time in Ruby lately, I'm not sure which I like more, the list comprehension pattern or Ruby's block-based syntax, e.g: some_collection.each do |item| item.do_thing end vs. [item.do_thing() for item in some_collection] While semantically they're the same thing, there's more one can do in the block the Ruby option provides compared to the comprehension approach. Different strokes for different folks :) -- - R. Tyler Croy -------------------------------------- Code: http://github.com/rtyler