Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.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; 'else:': 0.03; 'from:addr:yahoo.co.uk': 0.04; 'elif': 0.05; 'encoding': 0.05; 'mrab': 0.05; 'dan': 0.09; 'lawrence': 0.09; 'parsed': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:How': 0.10; 'python': 0.11; 'stored': 0.12; 'language.': 0.14; '3.3,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:unicode': 0.16; 'terms:': 0.16; '\xe9crit': 0.16; 'language': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'byte': 0.24; 'bytes': 0.24; 'mathematical': 0.24; 'number)': 0.24; 'parse': 0.24; "shouldn't": 0.24; 'unicode': 0.24; '---': 0.24; "i've": 0.25; 'options': 0.25; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'array': 0.29; 'characters': 0.30; 'waste': 0.30; 'code': 0.31; '>>>>': 0.31; 'probably': 0.32; 'subject:the': 0.34; 'common': 0.35; 'but': 0.35; 'subject:?': 0.36; 'sometimes': 0.38; 'depends': 0.38; 'feed': 0.38; 'to:addr:python-list': 0.38; 'heard': 0.39; 'realize': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'free': 0.61; 'march': 0.61; 'no.': 0.61; 'viruses': 0.61; 'complete': 0.62; 'email addr:gmail.com': 0.63; 'protection': 0.63; 'our': 0.64; 'more': 0.64; 'different': 0.65; 'details,': 0.68; 'antivirus': 0.68; 'internally.': 0.84; 'mars': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: How is unicode implemented behind the scenes? Date: Sun, 09 Mar 2014 14:53:05 +0000 References: <751cbe5d-ebbe-4f4e-93a9-6012667297e3@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host-92-24-221-174.ppp.as43234.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: X-Antivirus: avast! (VPS 140309-0, 09/03/2014), Outbound message X-Antivirus-Status: Clean 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: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394376810 news.xs4all.nl 2962 [2001:888:2000:d::a6]:41833 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68081 On 09/03/2014 10:32, Rustom Mody wrote: > On Sunday, March 9, 2014 2:09:32 PM UTC+5:30, wxjm...@gmail.com wrote: >> Le dimanche 9 mars 2014 03:40:28 UTC+1, MRAB a écrit : >>> On 2014-03-09 02:08, Dan Stromberg wrote: >>>> OK, I know that Unicode data is stored in an encoding on disk. >>>> But how is it stored in RAM? >>>> I realize I shouldn't write code that depends on any relevant >>>> implementation details, but knowing some of the more common >>>> implementation options would probably help build an intuition for >>>> what's going on internally. >>>> I've heard that characters are no longer all c bytes wide internally, >>>> so is it sometimes utf-8? >>> No. >>> From Python 3.3, it's an array of 1, 2 or 4 bytes per codepoint. >>> In Python terms: >>> if all(c <= '\xFF' for c in string): >>> use 1 byte per codepoint >>> elif all(c <= '\xFFFF' for c in string): >>> use 2 bytes per codepoint >>> else: >>> use 4 bytes per codepoint > >> A very, very nice recursive mathematical absurdity. > > As a profoundly astute mathematician > v v n r m a > can be parsed in 42 different ways (5th catalan number) > > Which parse did you intend? > > Please don't feed this particular troll, it's a complete waste of time. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com