classification
Title: _PyObject_LengthHint only accepts longs
Type: performance Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pjenvey Nosy List: benjamin.peterson, pjenvey, python-dev
Priority: normal Keywords: patch

Created on 2012-07-15 00:14 by pjenvey, last changed 2012-07-15 00:57 by python-dev. This issue is now closed.

Files
File name Uploaded Description Edit
lengthhint-fix.diff pjenvey, 2012-07-15 00:28 review
Messages (4)
msg165474 - (view) Author: Philip Jenvey (pjenvey) * (Python committer) Date: 2012-07-15 00:14
The __length_hint__ optimization was broken a while ago for many iterators due to a bug introduced in 44c090c74202. It only accepts longs as valid hints, not ints

This affects 2.6 too (but that's in security-only fix mode), but not 3.x
msg165475 - (view) Author: Philip Jenvey (pjenvey) * (Python committer) Date: 2012-07-15 00:28
attached a fix for review
msg165478 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2012-07-15 00:53
It's probably easier just to use PyNumber_Check.
msg165480 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-07-15 00:57
New changeset 872afada51b0 by Benjamin Peterson in branch '2.7':
allow any number to be returned from __length_hint__ (closes #15354)
http://hg.python.org/cpython/rev/872afada51b0
History
Date User Action Args
2012-07-15 00:57:08python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg165480

resolution: fixed
stage: resolved
2012-07-15 00:53:04benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg165478
2012-07-15 00:28:52pjenveysetfiles: + lengthhint-fix.diff
keywords: + patch
messages: + msg165475
2012-07-15 00:14:39pjenveycreate