On Feb 14, 10:19 am, Paul McGuire pt...@austin.rr.com wrote:
If func is expensive, you could try memoizing it. Then subsequent
calls just do arg lookups. Michele Simianato has posted a good
memoizing decorator on the Python wiki.
-- Paul
That's the trick! I almost forgot about that one.
On Feb 13, 7:44 pm, Basilisk96 basilis...@gmail.com wrote:
On Feb 12, 1:15 am, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
I usually strive
for comprehensions if a for loop can be reduced to such.
Any particular reason?
Only two.
1.) I was impressed by their clarity
On Feb 11, 7:22 pm, Basilisk96 basilis...@gmail.com wrote:
...
where func is a single-argument function that returns either a
string or None, but is an expensive call.
I am pretty sure that the sorted() construct cannot be improved much
further, but...
...does anyone have ideas on improving
On Feb 12, 1:15 am, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
I usually strive
for comprehensions if a for loop can be reduced to such.
Any particular reason?
Only two.
1.) I was impressed by their clarity and conciseness when I first
discovered them.
2.) I also read now
On Feb 11, 8:22 pm, Basilisk96 basilis...@gmail.com wrote:
Hello all,
I have the following function that uses an intermediate iterator
rawPairs:
def MakePairs(path):
import os
import operator
join = os.path.join
rawPairs = (
(join(path, s), func(s))
for
Hello all,
I have the following function that uses an intermediate iterator
rawPairs:
def MakePairs(path):
import os
import operator
join = os.path.join
rawPairs = (
(join(path, s), func(s))
for s in os.listdir(path)
if func(s) is not None and
En Wed, 11 Feb 2009 23:22:26 -0200, Basilisk96 basilis...@gmail.com
escribió:
def MakePairs(path):
import os
import operator
join = os.path.join
rawPairs = (
(join(path, s), func(s))
for s in os.listdir(path)
if func(s) is not None and
Don't use a generator then. If you're going to finally return a list (and
sorted does exactly that), build a list right from the start:
Good point. However, for the sake of argument, what if I removed the
sorting requirement and simply wanted the generator? I usually strive
for comprehensions
Basilisk96 wrote:
Don't use a generator then. If you're going to finally return a list (and
sorted does exactly that), build a list right from the start:
Good point. However, for the sake of argument, what if I removed the
sorting requirement and simply wanted the generator?
Write a
On Wed, 11 Feb 2009 20:26:12 -0800, Basilisk96 wrote:
Don't use a generator then. If you're going to finally return a list
(and sorted does exactly that), build a list right from the start:
Good point. However, for the sake of argument, what if I removed the
sorting requirement and simply
10 matches
Mail list logo