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.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'else:': 0.03; 'elif': 0.05; 'subject:Python': 0.06; 'width': 0.09; 'sat,': 0.16; 'wrote:': 0.18; 'adds': 0.24; 'char': 0.24; 'string,': 0.24; 'decide': 0.24; 'earlier': 0.24; 'versions': 0.24; 'subject:/': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'character': 0.29; '???': 0.30; 'message-id:@mail.gmail.com': 0.30; 'largest': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'another': 0.32; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'definition': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'received:209': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; '3.4': 0.84; 'subject:long': 0.84; 'inefficient': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=tbWVrNC3UCVF5zFEwMU+RXATwsxbgzKszCZ+eLh9jHI=; b=cvqLXLMlgfLW4N051RtAcQy2YUnQ+YokUPb46VxUAtfCV37ZmVh+e+hzTLeNWzE3Sa gAUM+1oHZ7icRiHk7muhoYKl3mQMCdU3i/fVmxvQuhjJnDTts3wfKg0/KDpaN8CUb6yR eY0jzQAPsE+w30MYpv83940cqDdNgOQveJLC9LFDsKTe6xqjCZ1d3nSIm5NM+1Km5z4J ilT/4ikm8VDOG9FD7tbInqRsU+AH2SKnMHKU8uui2b/OLJdw+jbkheV7gqAJvzb1/jRA hzWuBPviQaCfJnYFZbAmzCh1FBVHE/m9zmvFoVVohGZmExBBaJrbLAL5Zd02a5rYOEIS 38zw== X-Received: by 10.66.151.46 with SMTP id un14mr24521836pab.14.1365299922901; Sat, 06 Apr 2013 18:58:42 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <5160cbeb$0$29995$c3e8da3$5496439d@news.astraweb.com> References: <3qadncD4-6fcPsbMnZ2dnUVZ_rqdnZ2d@westnet.com.au> <515bbedb$0$29891$c3e8da3$5496439d@news.astraweb.com> <515be00e$0$29891$c3e8da3$5496439d@news.astraweb.com> <515c45ad$0$29966$c3e8da3$5496439d@news.astraweb.com> <5160cbeb$0$29995$c3e8da3$5496439d@news.astraweb.com> From: Ian Kelly Date: Sat, 6 Apr 2013 19:58:02 -0600 Subject: Re: Performance of int/long in Python 3 To: Python 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365299932 news.xs4all.nl 6887 [2001:888:2000:d::a6]:41844 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:42965 On Sat, Apr 6, 2013 at 7:29 PM, Steven D'Aprano wrote: > For some definition of "easily". > > if implementation == "CPython": > if version < "3.3": > if sys.maxunicode exists: > use it to decide whether this is a wide or narrow build > if a wide build: return 4 > else: return 2 > else: > ??? > elif version == "3.3": > scan the string, in some efficient or inefficient way > return 1, 2, 4 depending on the largest character you find > else: > ??? > else: > ??? None of which goes away if a char width function is added to 3.4 and you still want to support earlier versions as this does. It just adds another "if".