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 josh.r
Recipients josh.r, rhettinger
Date 2015-03-24.02:06:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1427162783.58.0.285913963641.issue23744@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2015-03-24 02:06:23josh.rsetrecipients: + josh.r, rhettinger
2015-03-24 02:06:23josh.rsetmessageid: <1427162783.58.0.285913963641.issue23744@psf.upfronthosting.co.za>
2015-03-24 02:06:23josh.rlinkissue23744 messages
2015-03-24 02:06:22josh.rcreate