Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] Internal representation of strings and Micropython

Daniel Holthdholth at gmail.com
Wed Jun 4 17:31:17 CEST 2014


On Wed, Jun 4, 2014 at 10:12 AM, Steven D'Aprano <steve at pearwood.info> wrote:> On Wed, Jun 04, 2014 at 01:14:04PM +0000, Steve Dower wrote:>> I'm agree with Daniel. Directly indexing into text suggests an>> attempted optimization that is likely to be incorrect for a set of>> strings.>> I'm afraid I don't understand this argument. The language semantics says> that a string is an array of code points. Every index relates to a> single code point, no code point extends over two or more indexes.> There's a 1:1 relationship between code points and indexes. How is> direct indexing "likely to be incorrect"?"Useful" is probably a better word. When you get into the complicatedlanguages and you want to know how wide something is, and you mighthave y with two dots on it as one code point or two and left-to-rightand right-to-left indicators and who knows what else... then lookingat individual code points only works sometimes. I get the slicingidea.I like the idea that encoding to utf-8 would be the fastest thing youcan do with a string. You could consider doing regexps in that domain,and other implementation specific optimizations in exactly the sameway that any Python implementation has them.None of this would make it harder to move a servo.


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp