Performance of int/long in Python 3

Ian Kelly ian.g.kelly at gmail.com
Wed Apr 3 03:06:33 EDT 2013


On Wed, Apr 3, 2013 at 12:52 AM, Chris Angelico <rosuav at gmail.com> wrote:
> Hmm. I was about to say "Can you just do a quick collections.Counter()
> of the string widths in 3.3, as an easy way of seeing which ones use
> BMP or higher characters", but I can't find a simple way to query a
> string's width. Can't see it as a method of the string object, nor in
> the string or sys modules. It ought to be easy enough at the C level -
> just look up the two bits representing 'kind' - but I've not found it
> exposed to Python. Is there anything?

4 if max(map(ord, s)) > 0xffff else 2 if max(map(ord, s)) > 0xff else 1



More information about the Python-list mailing list