04.04.13 00:57, Chris Angelico написав(ла):
On Thu, Apr 4, 2013 at 2:07 AM, Steven D'Aprano
<steve+comp.lang.pyt...@pearwood.info> wrote:
On Thu, 04 Apr 2013 01:17:28 +1100, Chris Angelico wrote:
Probably, but it still has to scan the body of the string. It'd not be
too bad if it's all astral, but if it's all BMP, it has to scan the
whole string. In the max() case, it has to scan the whole string anyway,
as there's no other way to determine the maximum. I'm thinking here of
this function:
http://pike.lysator.liu.se/generated/manual/modref/ex/7.2_3A_3A/String/
width.html
It's implemented as a simple lookup into the header. (Pike strings, like
PEP 393 strings, are stored in the most compact way possible - 1, 2, or
4 bytes per character - with a conceptually similar header structure.)
Is this something that would be worth having available? Should I post an
issue about it?
I'm not really sure why I would want to know, apart from pure
intellectual curiosity, but sure, post a feature request. Be sure to
mention that Pike supports this feature.
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.
--
http://mail.python.org/mailman/listinfo/python-list