Guido van Rossum <gu...@python.org> added the comment: 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32500> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com