comp.lang.ada
 help / color / mirror / Atom feed
From: "R. Tyler Croy" <tyler@linux.com>
Subject: Re: Iterators in Ada2012
Date: Wed, 9 Nov 2011 22:58:35 +0000 (UTC)
Date: 2011-11-09T22:58:35+00:00	[thread overview]
Message-ID: <j9f0ir$e78$1@dont-email.me> (raw)
In-Reply-To: m2k479brdd.fsf@pushface.org

On Wed, 09 Nov 2011 09:02:38 +0000, Simon Wright wrote:

> "R. Tyler Croy" <tyler@linux.com> 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



  reply	other threads:[~2011-11-09 22:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-08 10:05 Iterators in Ada2012 comp.lang.php
2011-11-08 13:13 ` Georg Bauhaus
2011-11-08 13:42   ` Dmitry A. Kazakov
2011-11-09  4:12   ` R. Tyler Croy
2011-11-09  9:02     ` Simon Wright
2011-11-09 22:58       ` R. Tyler Croy [this message]
2011-11-10  8:07         ` Georg Bauhaus
2011-11-09 10:55     ` Georg Bauhaus
2011-11-25 14:20       ` Yannick Duchêne (Hibou57)
2011-11-08 21:25 ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox