On Sat, 06 Apr 2013 14:58:23 -0700, Ethan Furman wrote: > On 04/06/2013 02:24 PM, Chris Angelico wrote: >> On Sat, Apr 6, 2013 at 8:09 PM, Serhiy Storchaka <storch...@gmail.com> >> wrote: >>> 04.04.13 00:57, Chris Angelico написав(ла): >>>> http://bugs.python.org/issue17629 opened. >>> >>> >>> See also the discussion at >>> http://comments.gmane.org/gmane.comp.python.ideas/15640 . I agree with >>> rejection. This is an implementation detail and different Python >>> implementations (including future CPython versions) can have different >>> internal string implementations. >> >> I really don't see why this means that there can't be a function in >> sys, or something. I mean, other Pythons aren't expected to return the >> exact same values from sys.getsizeof, are they? > > What it boils down to is: > > - it can easily be done by hand now
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: ??? > - it's a very uncommon need Well, that at least is true. But then, needing to know the platform you're running under, the size of objects, the id of a object, the largest integer, the largest float, or the number of references seen by the garbage collector are also uncommon needs. What really matters is not how often you need it, but what you can do when you need it if you don't have it. -- Steven -- http://mail.python.org/mailman/listinfo/python-list