Raymond Hettinger added the comment:

> The type of i and Py_SIZE(a) is Py_ssize_t, so when casted to 
> unsigned int, highest bits are lost. The correct casting type is size_t.

Yes, I had just seen that a early today and deciding whether to substitute 
size_t for the unsigned cast or whether to just revert.   I believe size_t is 
guaranteed to hold any array index and that a cast from non-negative Py_ssize_t 
would not lose bits.

> But in CPython implementation sizes are signed (Py_ssize_t). 
> The problem with using this optimization (rather low-level 
> than high-level) is that we need to know unsigned version of
> the type of compared values.

Wouldn't size_t always work for Py_ssize_t?

----------

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

Reply via email to