On Tue, 15 Feb 2011 18:55:50 -0500, Gerald Britton wrote:
> So, what's the feeling out there? Go with map and the operators or
> stick with the list comps?
Stick to whatever feels and reads better at the time.
Unless you have profiled your code, and determined that the map or list
comp was the
Generally, I prefer map() over list comprehensions since they are more
succinct and run faster for non-trivial examples. However, I've been
considering another use case related to functions in the operator
module. Here are some examples:
[x.method() for x in data]
[x[0] for x in data]
[x.attr fo
On Tue, 15 Feb 2011 14:32:13 +, Duncan Booth wrote:
>
>> Also, as already shown, the map version is faster.
>
> In most cases the list comprehension is faster. Try timing it.
For an extremely specialised and minimal definition of "most cases".
> C:\Python27>python.exe lib\timeit.py -s "de
>> I find:
>>
>> map(func, iterable)
>>
>> to be "neater" than:
>>
>> [func(item) for item in iterable]
>>
>> If nothing else, the "map" version is shorter.
>That's only true if you wanted to call an existing function. If you wanted
>to do something involving a more complex expression that
Gerald Britton wrote:
> I find:
>
> map(func, iterable)
>
> to be "neater" than:
>
> [func(item) for item in iterable]
>
> If nothing else, the "map" version is shorter.
That's only true if you wanted to call an existing function. If you wanted
to do something involving a more compl
I find:
map(func, iterable)
to be "neater" than:
[func(item) for item in iterable]
If nothing else, the "map" version is shorter. More importantly, in
the 2.x series (which I am often limited to for compatibility
reasons), the variable used in the list comprehension leaks to the
follow
Il giorno 15/feb/2011, alle ore 04.10, Ben Finney ha scritto:
> Andrea Crotti writes:
> The ‘map’ builtin is deprecated; using a list comprehension is neater
> and more efficient.
Ok well it depends,
map(int, biglist)
is better than:
[int(x) for x in biglist]
at least for me.
Efficiency is pro
Steven D'Aprano writes:
> On Tue, 15 Feb 2011 14:10:38 +1100, Ben Finney wrote:
> > The ‘map’ builtin is deprecated;
>
> I don't believe it is. Do you have any evidence for this claim?
I was mis-remembering PEP 3100.
Anyway, I regard it as deprecated; list comprehensions are more flexible
and
On Tue, 15 Feb 2011 14:10:38 +1100, Ben Finney wrote:
> Andrea Crotti writes:
>
>> I work on emacs with flymake activated and pylint, pyflakes and pep8
>> running in background to notify for some style problems.
>>
>> Now there are at a couple of pylint warnings which I don't understand
>> 1. Wa
Andrea Crotti writes:
> I work on emacs with flymake activated and pylint, pyflakes and pep8
> running in background to notify for some style problems.
>
> Now there are at a couple of pylint warnings which I don't understand
> 1. Warning (W, filter_enums): Used builtin function 'map' [2 times]
>
On Mon, Feb 14, 2011 at 3:48 PM, Andrea Crotti
wrote:
> I work on emacs with flymake activated and pylint, pyflakes and pep8 running
> in background to notify for some style problems.
>
> Now there are at a couple of pylint warnings which I don't understand
> 1. Warning (W, filter_enums): Used bu
I work on emacs with flymake activated and pylint, pyflakes and pep8 running in
background to notify for some style problems.
Now there are at a couple of pylint warnings which I don't understand
1. Warning (W, filter_enums): Used builtin function 'map' [2 times]
what is the problem with using ma
12 matches
Mail list logo