> > In python comprehensions on [] makes a list and comprehensions in {}
> > make a dictionary (list and dict comprehensions). As PHP only has one
> > 'array' type using [] makes sense. Along that train of thought, should
> > comprehensions also be possible in the old array() syntax?
>
> Honestly, I cannot think of any case where I'd use a comprehension where I 
> would definitely want an array and not a generator.  In the majority case 
> both work equally well, cool, but I don't know when I would even use an 
> array-dependent version.  And converting from a generator to an array is 
> trivial; the other way, very not so much.
>

Would there be any notable performance difference? I'd expect the case
where one actually wanted the whole array to be slower if it was going
through a generator, vs a tight loop, due to the additional level of
indirection.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to