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 gvanrossum
Recipients docs@python, gvanrossum, mgorny, serhiy.storchaka
Date 2018-01-06.17:02:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
If we were to take the docs literally then PySequence_{Size,Length} should just be aliases for PyObject_Size.  But I'm reluctant to change something that has been like this for ages.

In fact maybe we should deprecate them, together with other PySequence_ and PyMapping_ operations that have more general PyObject_ alternatives?

You can read the source code to find the root cause for the behavior -- PySequence_{Size,Length} only looks for tp_as_sequence->sq_length, but dict has that field set to NULL.  (A dict's size is computed by tp_as_mapping->mp_length.)

Fixing dict by adding a redundant sq_length seems brittle (there may be many other mapping types with similar issues).

So I think we should update the docs to recommend PyObject_Size instead.
Date User Action Args
2018-01-06 17:02:24gvanrossumsetrecipients: + gvanrossum, docs@python, mgorny, serhiy.storchaka
2018-01-06 17:02:24gvanrossumsetmessageid: <>
2018-01-06 17:02:24gvanrossumlinkissue32500 messages
2018-01-06 17:02:24gvanrossumcreate