Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'mrab': 0.05; 'say,': 0.05; '21,': 0.07; 'ascii': 0.07; 'referring': 0.07; 'python': 0.09; 'compression': 0.09; 'non-ascii': 0.09; 'regression': 0.09; 'subject:()': 0.09; 'dec': 0.15; 'properly': 0.15; 'cases:': 0.16; 'coding?': 0.16; 'exploits': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:3.3': 0.16; 'subject:unicode': 0.16; 'unequal': 0.16; 'string': 0.17; 'wrote:': 0.17; 'comparing': 0.17; 'ideal': 0.20; 'fairly': 0.21; '(usually': 0.22; "haven't": 0.23; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'coding': 0.27; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'build,': 0.29; 'character': 0.29; 'usually': 0.30; 'fri,': 0.30; 'up.': 0.31; 'code': 0.31; 'file': 0.32; 'more,': 0.32; 'to:addr:python-list': 0.33; 'program,': 0.34; 'received:google.com': 0.34; 'text': 0.34; 'same.': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'characters': 0.36; 'depends': 0.36; 'two': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'sure': 0.38; 'performance': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'most': 0.61; 'subject:, ': 0.61; 'wide': 0.62; 'world': 0.63; 'ever': 0.63; 'email addr:gmail.com': 0.63; 'show': 0.63; 'treat': 0.65; 'obvious': 0.71; 'unusual': 0.71; 'beats': 0.84; 'dramatically': 0.84; 'technique': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=RcnSIQ6Fp1tOHA4AYhsXdiOUS7HujP4RFc19ssltjDA=; b=w5XeuKxzADRkGZMQgfw0ZqwGoiq0xARHkSieqyB/chRif3gDsk218apAk2tm0DM4/N rdx8Ec1QthBl9IsTVe299vjBmlvJw3mt/5Rtsp6Bv4hZQLdliTNtPRGrfG3PmES3S8NI zZ/1PA8CZe0Vj5KoRvomvDr8w18T/Foqp/gMMt6IiIW2nbmL6POkQXaBAcP3b7ZwfpVP 00VSyPTJcTf10Cj5M7gbjCHX/6JjdoJosjv8f56l8lWGYnOKoV0ZFJszK/y4LZYw+/A2 70JV8mHJOiMu6Yx+rvRwErUd8USC0e3n4vzF6ABZc8fENOYEA6WlUXflT9jXtvLykcwb zpJQ== MIME-Version: 1.0 In-Reply-To: <50D37329.6000009@mrabarnett.plus.com> References: <2adb4a25-8ea3-441f-b8c0-ee6c87e4b19f@googlegroups.com> <50D37329.6000009@mrabarnett.plus.com> Date: Fri, 21 Dec 2012 08:19:11 +1100 Subject: Re: Py 3.3, unicode / upper() From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1356038360 news.xs4all.nl 6939 [2001:888:2000:d::a6]:43435 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35230 On Fri, Dec 21, 2012 at 7:20 AM, MRAB wrote: > On 2012-12-20 19:19, wxjmfauth@gmail.com wrote: >> The rule is to treat every character of a unique set of characters >> of a coding scheme in, how to say, an "equal way". The problematic >> can be seen the other way, every coding scheme has been built >> to work with a unique set of characters, otherwhile it is not >> properly working! >> > It's true that in an ideal world you would treat all codepoints the > same. However, this is a case where "practicality beats purity". Actually no. Not all codepoints are the same. Ever heard of Huffman coding? It's a broad technique used in everything from PK-ZIP/gzip file compression to the Morse code ("here come dots!"). It exploits and depends on a dramatically unequal usage distribution pattern, as all text (he will ask "All?" You will respond "All!" He will understand -- referring to Caeser) exhibits. In the case of strings in a Python program, it's fairly obvious that there will be *many* that are ASCII-only; and what's more, most of the long strings will either be ASCII-only or have a large number of non-ASCII characters. However, your microbenchmarks usually look at two highly unusual cases: either a string with a huge number of ASCII chars and one non-ASCII, or all the same non-ASCII (usually for your replace() tests). I haven't seen strings like either of those come up. Can you show us a performance regression in an *actual* *production* *program*? And make sure you're comparing against a wide build, here. ChrisA