[Patches] [ python-Patches-754632 ] Enhance xrange description by mentioning itertools.repeat
SourceForge.net
noreply@sourceforge.net
Sat, 28 Jun 2003 07:06:18 -0700
Patches item #754632, was opened at 2003-06-14 14:52
Message generated for change (Comment added) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=754632&group_id=5470
Category: Documentation
Group: Python 2.3
>Status: Closed
>Resolution: Rejected
Priority: 5
Submitted By: Gerrit Holl (gerrit)
Assigned to: Nobody/Anonymous (nobody)
Summary: Enhance xrange description by mentioning itertools.repeat
Initial Comment:
This patch lets the description of the xrange builtin
function include the recently by Alex Martelli on
python-dev described notion that itertools.repeat(None,
n) may be a lot faster than range() or xrange().
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2003-06-28 09:06
Message:
Logged In: YES
user_id=80475
Though "for _ in itertools.repeat(None, n):" offers a small
speed advantage, it is not as readable as "for i in xrange(n):"
which should remain the preferred looping idiom.
The purpose of itertools.repeat() is to supply repeated
arguments to imap() and izip(). Its secondary purpose is to
provide a memory friendly version of "[obj] * n". Using it as
a speedup for xrange() should only be used in rare situations
where a slight performance gain is essential.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=754632&group_id=5470