Josh Rosenberg added the comment:

On further checking, this probably gives slightly greater benefit to deque than 
it would for list, tuple, dict, etc., only because PyObject_IsTrue checks for 
mapping before sequence; deque is a pure sequence, no mapping, so it has to 
fail an extra test before it reaches the sequence length interface check and 
uses it, where any sequence that supports extended slicing must support parts 
of the mapping interface, and usually copies the sequence function pointer to 
the mapping length slot as well.

Still hard to justify, though. Testing the truthiness of a deque is not likely 
to be the critical code path for many applications (if you want to take 
advantage of deque's atomic behaviors, you're using EAFP patterns anyway, not 
testing truthiness), and the gain in boolean testing means other (likely low 
probability tests) will run slower (for example, testing a deque with 
PyNumber_Check would go slower, because it would pass an extra test before 
failing each time).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23744>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to