Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed6.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; 'string.': 0.04; 'parsing': 0.07; 'utf-8': 0.07; 'subject:How': 0.09; 'python': 0.09; 'bytes,': 0.09; 'subject:()': 0.09; 'subject:string': 0.09; 'subject:using': 0.09; 'stored': 0.10; 'aug': 0.13; 'index': 0.13; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'somewhere.': 0.16; 'subject:unicode': 0.16; 'subject:variable': 0.16; 'uncommon': 0.16; 'string': 0.17; 'wrote:': 0.17; '>>>': 0.18; 'received:209.85.214.174': 0.21; 'paul': 0.24; 'header:In- Reply-To:1': 0.25; 'opposed': 0.27; 'message-id:@mail.gmail.com': 0.27; 'chris': 0.28; 'writes:': 0.29; 'structure': 0.32; 'could': 0.32; 'to:addr:python-list': 0.33; 'that,': 0.34; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'data.': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'subject:value': 0.84; 'inefficient': 0.91; 'imagine': 0.96 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=OOsJv0yf9C2oDIipN50H+3nX2ISoDrj68cpFWFJODMY=; b=lRxvia0Oz2KiR18HLJ2blGzH/xyeYJBh9zkkotyq5gWKPmr691YFCaH1USQjH7VqW0 VP1LF7a5MohgI6Yu1TJ3pRx0Uk2h36zmp/CkYv68a1wbFuNplIofbelMx4MJ4b0dvHfc J+C2VTRNNBU5RFHehiEFIc8FEyeYNrrQX6UZaG/CAKlvECENisBu4LPSTPnrB+t+o1ix d2AycJESv/ViDNPQrWXsAlSuCTXAgtduN+u7xXPPa/tLUor7go79qJ4l41oc0v/E8t/e esrr6cBi3tQUheF4cRMmPY5YovEg/kesuCoM+UzCCO3juP5lE7dkEJBOqhjN6L0B2T7c jZug== MIME-Version: 1.0 In-Reply-To: <7xfw7j3a1x.fsf@ruckus.brouhaha.com> References: <308df2af-abe7-4043-b199-0a39f440e0ab@googlegroups.com> <502f8a2a$0$29978$c3e8da3$5496439d@news.astraweb.com> <7xehn4vyya.fsf@ruckus.brouhaha.com> <7xfw7j3a1x.fsf@ruckus.brouhaha.com> Date: Sun, 19 Aug 2012 12:19:00 +1000 Subject: Re: How do I display unicode value stored in a string variable using ord() 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.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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345342743 news.xs4all.nl 6850 [2001:888:2000:d::a6]:37112 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27338 On Sun, Aug 19, 2012 at 12:11 PM, Paul Rubin wrote: > Chris Angelico writes: >> UTF-8 is highly inefficient for indexing. Given a buffer of (say) a >> few thousand bytes, how do you locate the 273rd character? > > How often do you need to do that, as opposed to traversing the string by > iteration? Anyway, you could use a rope-like implementation, or an > index structure over the string. Well, imagine if Python strings were stored in UTF-8. How would you slice it? >>> "asdfqwer"[4:] 'qwer' That's a not uncommon operation when parsing strings or manipulating data. You'd need to completely rework your algorithms to maintain a position somewhere. ChrisA