This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients Claudiu.Popa, abingham, benjamin.peterson, rhettinger, vstinner
Date 2014-03-14.09:00:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1394787602.64.0.643347645096.issue19359@psf.upfronthosting.co.za>
In-reply-to
Content
Thanks for looking at this.

Putting in a special case for weak references isn't the way to go.  The problem is that _PyObject_LookupSpecial isn't working well with weakref proxies.

A solution for reversed() could be to replace ``PyObject_GetAttrString(seq, "__reversed__")`` with the slower call to ``_PyObject_LookupSpecial(seq, "__reversed__", &reversed_cache);``.

The unfortunate downside is that this would slow down the common cases.

Another solution is to patch _PyObject_LookupSpecial to make it smarter with respect to weakref objects or possibly use a fallback to PyObject_GetAttrString when a method isn't found using the speedy lookup.

The advantage of fixing _PyObject_LookupSpecial is that it fixes all uses of _PyObject_LookupSpecial not just reversed().  Also, it would keep the current speed benefit for the common case.

I'm reassigning to Benjamin because it was his optimized that broke the ability to find the __reversed__ method on a proxy object.

Another issue that needs to be looked at is whether PySequence_Check() needs to be made aware of weakref proxies.
History
Date User Action Args
2014-03-14 09:00:02rhettingersetrecipients: + rhettinger, vstinner, benjamin.peterson, Claudiu.Popa, abingham
2014-03-14 09:00:02rhettingersetmessageid: <1394787602.64.0.643347645096.issue19359@psf.upfronthosting.co.za>
2014-03-14 09:00:02rhettingerlinkissue19359 messages
2014-03-14 09:00:01rhettingercreate