Performance of int/long in Python 3

Ian Kelly ian.g.kelly at gmail.com
Sat Apr 6 21:58:02 EDT 2013


On Sat, Apr 6, 2013 at 7:29 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> For some definition of "easily".
>
> if implementation == "CPython":
>     if version < "3.3":
>         if sys.maxunicode exists:
>             use it to decide whether this is a wide or narrow build
>             if a wide build: return 4
>             else: return 2
>         else:
>             ???
>     elif version == "3.3":
>         scan the string, in some efficient or inefficient way
>         return 1, 2, 4 depending on the largest character you find
>     else:
>         ???
> else:
>     ???

None of which goes away if a char width function is added to 3.4 and
you still want to support earlier versions as this does.  It just adds
another "if".



More information about the Python-list mailing list