Message309557
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:24 | gvanrossum | set | recipients:
+ gvanrossum, docs@python, mgorny, serhiy.storchaka |
2018-01-06 17:02:24 | gvanrossum | set | messageid: <1515258144.71.0.467229070634.issue32500@psf.upfronthosting.co.za> |
2018-01-06 17:02:24 | gvanrossum | link | issue32500 messages |
2018-01-06 17:02:24 | gvanrossum | create | |
|