Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'encoding': 0.05; 'string.': 0.05; '*not*': 0.07; 'utf-8': 0.07; 'string': 0.09; 'assuming': 0.09; 'lookup': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'scheme.': 0.09; 'strings.': 0.09; 'width': 0.09; 'python': 0.11; 'jan': 0.12; 'posted': 0.15; 'easier.': 0.16; 'encodings,': 0.16; 'lookups.': 0.16; 'notation,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'slice.': 0.16; 'slow,': 0.16; 'subject:unicode': 0.16; 'so.': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'coding': 0.22; 'header:User-Agent:1': 0.23; 'unicode': 0.24; 'least': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'michael': 0.29; 'chris': 0.29; 'am,': 0.29; 'array': 0.29; "i'm": 0.30; 'comments': 0.31; 'languages': 0.32; 'says': 0.33; 'cases': 0.33; 'but': 0.35; 'method': 0.36; 'similar': 0.36; 'should': 0.36; 'application': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'space': 0.40; 'days': 0.60; 'ago,': 0.61; 'ago.': 0.61; 'length': 0.61; 'received:173': 0.61; 'more': 0.64; 'below.': 0.71; 'received:fios.verizon.net': 0.84; 'unacceptable': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: FSR and unicode compliance - was Re: RE Module Performance Date: Sun, 28 Jul 2013 13:36:00 -0400 References: <571a6dfe-fd66-42cf-92fc-8b97cbe6e9e4@googlegroups.com> <51DFDE65.5040001@Gmail.com> <4f1067f6-bc99-42ad-9166-37fb228b90e8@googlegroups.com> <51f14395$0$29971$c3e8da3$5496439d@news.astraweb.com> <51f15e03$0$29971$c3e8da3$5496439d@news.astraweb.com> <8203e802-9dc5-44c5-9547-6e1947ee224b@googlegroups.com> <51F53E4F.8080104@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 In-Reply-To: <51F53E4F.8080104@gmail.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375032989 news.xs4all.nl 15997 [2001:888:2000:d::a6]:43732 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51389 On 7/28/2013 11:52 AM, Michael Torrie wrote: > > 3. UTF-8 and UTF-16 encodings, being variable width encodings, mean that > slicing a string would be very very slow, Not necessarily so. See below. > and that's unacceptable for > the use cases of python strings. I'm assuming you understand big O > notation, as you talk of experience in many languages over the years. > FSR and UTF-32 both are O(1) for slicing and lookups. Slicing is at least O(m) where m is the length of the slice. > UTF-8, 16 and any variable-width encoding are always O(n).\ I posted about a week ago, in response to Chris A., a method by which lookup for UTF-16 can be made O(log2 k), or perhaps more accurately, O(1+log2(k+1)), where k is the number of non-BMP chars in the string. This uses an auxiliary array of k ints. An auxiliary array of n ints would make UFT-16 lookup O(1), but then one is using more space than with UFT-32. Similar comments apply to UTF-8. The unicode standard says that a single strings should use exactly one coding scheme. It does *not* say that all strings in an application must use the same scheme. I just rechecked a few days ago. It also does not say that an application cannot associate additional data with a string to make processing of the string easier. -- Terry Jan Reedy