[issue19369] PyObject_LengthHint is slow

2013-10-24 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- resolution: -> fixed stage: -> committed/rejected status: open -> closed ___ Python tracker ___ ___

[issue19369] PyObject_LengthHint is slow

2013-10-24 Thread Roundup Robot
Roundup Robot added the comment: New changeset bffb49efc383 by Serhiy Storchaka in branch 'default': Issue #19369: Optimized the usage of __length_hint__(). http://hg.python.org/cpython/rev/bffb49efc383 -- nosy: +python-dev ___ Python tracker

[issue19369] PyObject_LengthHint is slow

2013-10-24 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- assignee: -> serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue19369] PyObject_LengthHint is slow

2013-10-24 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Here is a patch which uses _PyObject_HasLen. It has same performance > but is much simpler. +1 This will be a nice improvement. -- ___ Python tracker

[issue19369] PyObject_LengthHint is slow

2013-10-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Here is a patch which uses _PyObject_HasLen. It has same performance > but is much simpler. Thanks! -- ___ Python tracker ___ ___

[issue19369] PyObject_LengthHint is slow

2013-10-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Here is a patch which uses _PyObject_HasLen. It has same performance but is much simpler. -- Added file: http://bugs.python.org/file32323/lengthhint_2.patch ___ Python tracker _

[issue19369] PyObject_LengthHint is slow

2013-10-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: What if use _PyObject_HasLen? if (_PyObject_HasLen(o)) { res = PyObject_Length(o); ... } hint = _PyObject_LookupSpecial(o, &PyId___length_hint__); ... -- nosy: +serhiy.storchaka ___ Python tracker

[issue19369] PyObject_LengthHint is slow

2013-10-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: Here is a patch. Micro-benchmark: $ ./python -m timeit -s "l=[]; it=(x for x in ())" "l.extend(it)" -> before: 0.449 usec per loop -> after: 0.179 usec per loop -- keywords: +patch Added file: http://bugs.python.org/file32318/lengthhint.patch _

[issue19369] PyObject_LengthHint is slow

2013-10-23 Thread Antoine Pitrou
New submission from Antoine Pitrou: PyObject_LengthHint is in the critical patch for many operations (such as list constructor, or list.extend), but it's quite unoptimized. -- components: Interpreter Core messages: 201060 nosy: benjamin.peterson, pitrou, rhettinger priority: normal seve