Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!feed.xsnews.nl!border-2.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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; 'skip:[ 20': 0.03; 'explicitly': 0.04; 'mrab': 0.05; 'sys': 0.05; 'ascii': 0.07; 'strings.': 0.07; 'subject:How': 0.09; 'python': 0.09; '"a"': 0.09; '51,': 0.09; '75,': 0.09; 'bytes,': 0.09; 'pep': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:()': 0.09; 'subject:string': 0.09; 'subject:using': 0.09; 'stored': 0.10; 'aug': 0.13; 'sat,': 0.15; '3.2.': 0.16; '52,': 0.16; '54,': 0.16; '55,': 0.16; '57,': 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:3.3': 0.16; 'subject:unicode': 0.16; 'subject:variable': 0.16; 'wrote:': 0.17; 'byte': 0.17; 'bytes': 0.17; '>>>': 0.18; 'import': 0.21; '(on': 0.22; 'constant': 0.22; 'linux': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; 'skip:( 20': 0.28; '+0100,': 0.29; '50,': 0.29; 'character.': 0.29; "d'aprano": 0.29; 'overhead': 0.29; 'steven': 0.29; '(2)': 0.32; 'not.': 0.32; 'getting': 0.33; 'to:addr:python-list': 0.33; '(1)': 0.34; 'formats': 0.35; 'received:org': 0.36; 'does': 0.37; 'uses': 0.37; 'subject:New': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'subject:, ': 0.61; 'system)': 0.61; 'more': 0.63; '100': 0.78; '81,': 0.84; 'subject:value': 0.84; '74,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: New internal string format in 3.3, was Re: How do I display unicode value stored in a string variable using ord() Date: Sun, 19 Aug 2012 09:43:13 +0200 Organization: None References: <308df2af-abe7-4043-b199-0a39f440e0ab@googlegroups.com> <502f8a2a$0$29978$c3e8da3$5496439d@news.astraweb.com> <4c62a649-bc21-4e47-9c0f-acb1b1e70e36@googlegroups.com> <5030891f$0$29978$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Gmane-NNTP-Posting-Host: p50849f38.dip.t-dialin.net User-Agent: KNode/4.7.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345362201 news.xs4all.nl 6920 [2001:888:2000:d::a6]:49607 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27357 Steven D'Aprano wrote: > On Sat, 18 Aug 2012 19:34:50 +0100, MRAB wrote: > >> "a" will be stored as 1 byte/codepoint. >> >> Adding "é", it will still be stored as 1 byte/codepoint. > > Wrong. It will be 2 bytes, just like it already is in Python 3.2. > > I don't know where people are getting this myth that PEP 393 uses Latin-1 > internally, it does not. Read the PEP, it explicitly states that 1-byte > formats are only used for ASCII strings. From Python 3.3.0a4+ (default:10a8ad665749, Jun 9 2012, 08:57:51) [GCC 4.6.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> [sys.getsizeof("é"*i) for i in range(10)] [49, 74, 75, 76, 77, 78, 79, 80, 81, 82] >>> [sys.getsizeof("e"*i) for i in range(10)] [49, 50, 51, 52, 53, 54, 55, 56, 57, 58] >>> sys.getsizeof("é"*101)-sys.getsizeof("é") 100 >>> sys.getsizeof("e"*101)-sys.getsizeof("e") 100 >>> sys.getsizeof("€"*101)-sys.getsizeof("€") 200 I infer that (1) both ASCII and Latin1 strings require one byte per character. (2) Latin1 strings have a constant overhead of 24 bytes (on a 64bit system) over ASCII-only.