Performance of int/long in Python 3

Ian Kelly ian.g.kelly at gmail.com
Sun Apr 7 01:22:29 EDT 2013


On Sat, Apr 6, 2013 at 8:18 PM, Roy Smith <roy at panix.com> wrote:
> In article <mailman.222.1365299932.3114.python-list at python.org>,
>  Ian Kelly <ian.g.kelly at gmail.com> wrote:
>
>> 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".
>
> The same is true of any new feature.  That doesn't mean we shouldn't add
> new features.

If you're interested in backward compatibility, then as noted the
feature doesn't really make things any simpler for you.  Otherwise,
the only implementation that matters from the above is the 3.3 one,
which isn't much more complex.



More information about the Python-list mailing list