New submission from Kyle <[email protected]>:
Using pypy2.0-beta1 I have managed to get performance boost up to 20x (for
integers) and up to 10x (for strings) of min()/max() functions when
reimplemented
them in pure python as follows:
def min_(arg):
seq = iter(arg)
head = seq.next()
return reduce(min, seq, head) # min called with two args
# With exception handling for empty sequence:
def min_(arg):
seq = iter(arg) # throws TypeError for non-iterables
try:
head = seq.next()
except StopIteration:
raise ValueError('arg is an empty sequence')
return reduce(min, seq, head)
Could you please investigate performance on your side? I understand that
min/max
functions should also fallback to compare function for two (or small amount of)
arguments, but given large sequences we can neglect this difference.
----------
messages: 5411
nosy: dbud, pypy-issue
priority: performance bug
release: 2.0
status: unread
title: min()/max() performance
________________________________________
PyPy bug tracker <[email protected]>
<https://bugs.pypy.org/issue1414>
________________________________________
_______________________________________________
pypy-issue mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-issue