Path: csiph.com!usenet.pasdenom.info!news.albasani.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'sys': 0.05; 'locale': 0.07; 'suppose': 0.07; 'python': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:string': 0.09; '3.2.': 0.16; '509': 0.16; 'experiments': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'subject:unicode': 0.16; 'wrote:': 0.17; 'memory': 0.18; 'import': 0.21; 'least': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; '20%': 0.29; 'cat': 0.29; 'words': 0.29; 'this.': 0.29; 'skip:s 30': 0.33; 'builds': 0.33; 'to:addr:python-list': 0.33; "can't": 0.34; 'text': 0.34; 'skip:l 30': 0.35; 'received:org': 0.36; 'skip:p 20': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'subject:, ': 0.61; 'wide': 0.62; 'situation': 0.62; 'subject:...': 0.63; 'email addr:gmail.com': 0.63; 'more': 0.63; 'confirm': 0.64; 'total': 0.65; 'gain': 0.79; 'subject:, ...': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Flexible string representation, unicode, typography, ... Date: Mon, 03 Sep 2012 08:15:30 +0200 Organization: None References: <503a0d51$0$6574$c3e8da3$5496439d@news.astraweb.com> <503a8361$0$6574$c3e8da3$5496439d@news.astraweb.com> <2e92da71-fbd2-467f-9088-1c79fa7bcf69@googlegroups.com> <62566024-df1d-4948-a27a-45c7820ddc6c@googlegroups.com> <503f0e45$0$9416$c3e8da3$76491128@news.astraweb.com> <2a12ba52-232a-41b7-a906-1ec379bbddd7@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Gmane-NNTP-Posting-Host: p508497bc.dip.t-dialin.net User-Agent: KNode/4.7.3 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346652940 news.xs4all.nl 6846 [2001:888:2000:d::a6]:38443 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28340 wxjmfauth@gmail.com wrote: > Le dimanche 2 septembre 2012 14:01:18 UTC+2, Serhiy Storchaka a écrit : >> Hmm, and with locale.strxfrm Python 3.3 20% slower than 3.2. > > With a memory gain = 0 since my text contains non-latin-1 characters! I can't confirm this. At least users of wide builds will see a decrease in memory use: $ cat strxfrm_getsize.py import locale import sys print("maxunicode:", sys.maxunicode) locale.setlocale(locale.LC_ALL, "fr_FR.UTF-8") words = [ 'noël', 'noir', 'nœud', 'noduleux', 'noétique', 'noèse', 'noirâtre'] print("total size of original strings:", sum(sys.getsizeof(s) for s in words)) print( "total size of transformed strings:", sum(sys.getsizeof(locale.strxfrm(s)) for s in words)) $ python3.2 strxfrm_getsize.py maxunicode: 1114111 total size of original strings: 584 total size of transformed strings: 980 $ python3.3 strxfrm_getsize.py maxunicode: 1114111 total size of original strings: 509 total size of transformed strings: 483 The situation is more complex than you suppose -- you need less dogma and more experiments ;)