Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'skip:[ 20': 0.04; '(unicode': 0.09; 'python': 0.11; 'codec': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'subject:Unicode': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'example': 0.22; 'header:User-Agent:1': 0.23; 'bytes': 0.24; 'unicode': 0.24; 'header:In-Reply-To:1': 0.27; 'strongly': 0.30; '"",': 0.31; '>>>>': 0.31; 'file': 0.32; '(most': 0.33; 'third': 0.33; "can't": 0.35; 'problem.': 0.35; 'done.': 0.35; 'test': 0.35; 'version': 0.36; 'next': 0.36; 'wrong': 0.37; 'handle': 0.38; 'skip:[ 10': 0.38; 'to:addr:python- list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'skip:u 10': 0.60; 'skip:y 20': 0.60; 'email addr:gmail.com': 0.63; 'more': 0.64 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=ZphjKrLG c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=tLkI8qN_j18A:10 a=ihvODaAuJD4A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=pGLkceISAAAA:8 a=te1EGT4yAAAA:8 a=__4xaf3E1wuR-8WYVPwA:9 a=QEXdDO2ut3YA:10 a=MaVR9jfi3RAA:10 a=MSl-tDqOz04A:10 X-AUTH: mrabarnett:2500 Date: Tue, 29 Apr 2014 19:12:43 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Unicode 7 References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1398795170 news.xs4all.nl 2919 [2001:888:2000:d::a6]:52014 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70724 On 2014-04-29 18:37, wxjmfauth@gmail.com wrote: > Let see how Python is ready for the next Unicode version > (Unicode 7.0.0.Beta). > > >>>> timeit.repeat("(x*1000 + y)[:-1]", setup="x = 'abc'; y = 'z'") > [1.4027834829454946, 1.38714224331963, 1.3822586635296261] >>>> timeit.repeat("(x*1000 + y)[:-1]", setup="x = 'abc'; y = '\u0fce'") > [5.462776291480395, 5.4479432055423445, 5.447874284053398] >>>> >>>> >>>> # more interesting >>>> timeit.repeat("(x*1000 + y)[:-1]",\ > ... setup="x = 'abc'.encode('utf-8'); y = '\u0fce'.encode('utf-8')") > [1.3496489533188765, 1.328654286266783, 1.3300913977710707] >>>> > Although the third example is the fastest, it's also the wrong way to handle Unicode: >>> x = 'abc'.encode('utf-8'); y = '\u0fce'.encode('utf-8') >>> t = (x*1000 + y)[:-1].decode('utf-8') Traceback (most recent call last): File "", line 1, in UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 3000-3001: unex pected end of data > Note 1: "lookup" is not the problem. > > Note 2: From Unicode.org : "[...] We strongly encourage [...] and test > them with their programs [...]" > > -> Done. > > jmf >