Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.106 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.79; '*S*': 0.00; 'string': 0.09; 'character.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'points:': 0.16; 'unfair': 0.16; 'wrote:': 0.18; 'slightly': 0.19; '>>>': 0.22; 'bytes': 0.24; 'fixed.': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'characters': 0.30; 'message-id:@mail.gmail.com': 0.30; '>>>>': 0.31; 'overhead': 0.31; 'figure': 0.32; 'fri,': 0.33; 'skip:s 30': 0.35; 'requirement': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'two': 0.37; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'cost.': 0.60; 'most': 0.60; 'simple': 0.61; 'charset:windows-1252': 0.65; 'between': 0.67; '26,': 0.68; 'fact,': 0.69; 'jul': 0.74; '2013': 0.98 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:content-transfer-encoding; bh=KTrUdGv5zI6ZoNErqpgAq4X7ZjNmgrhLcGTYRxvfqSs=; b=R1SRCN8FsT0UokvhI2Sh09RiAx09ooYHjn0G5o8vjVlNic5t/LtWnfh3Nd9QKcXDVr 5p4R8DC4iBwuVg2tt4KF9suZT1+Y57CDkzKog5V1OvlgQD3EsWDLIKDTXrgxQwEezTV1 etMDVedjqhR2oNjakPvCzuES9fxwVmoY6R1ovLJ9/5db6Cm4yOhv8HP06jkwYZGkbBMM kXEZZgS9G0ey5aRAuk0QuA56kLkC4Wj869lfG2QGq4I/YXnQVEkhQu0inT87TW4ZwgHl ZdGdtYcengvN25jILH9Gwf/dhrTwJ5OMCqUc4c0HI1LhbFuzTtxaakGxQn0pbGI15Ee1 4sOw== MIME-Version: 1.0 X-Received: by 10.52.163.165 with SMTP id yj5mr5733468vdb.104.1374779924725; Thu, 25 Jul 2013 12:18:44 -0700 (PDT) In-Reply-To: <741eaf38-6655-4763-8962-748408e7c2d8@googlegroups.com> References: <571a6dfe-fd66-42cf-92fc-8b97cbe6e9e4@googlegroups.com> <51DFDE65.5040001@Gmail.com> <4f1067f6-bc99-42ad-9166-37fb228b90e8@googlegroups.com> <0420de60-b9b5-4ac4-ba7b-ca5ac2ca65fe@googlegroups.com> <741eaf38-6655-4763-8962-748408e7c2d8@googlegroups.com> Date: Fri, 26 Jul 2013 05:18:44 +1000 Subject: Re: RE Module Performance From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374779934 news.xs4all.nl 15958 [2001:888:2000:d::a6]:46621 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51254 On Fri, Jul 26, 2013 at 5:07 AM, wrote: > Let start with a simple string \textemdash or \texttendash > >>>> sys.getsizeof('=96') > 40 >>>> sys.getsizeof('a') > 26 Most of the cost is in those two apostrophes, look: >>> sys.getsizeof('a') 26 >>> sys.getsizeof(a) 8 Okay, that's slightly unfair (bonus points: figure out what I did to make this work; there are at least two right answers) but still, look at what an empty string costs: >>> sys.getsizeof('') 25 Or look at the difference between one of these characters and two: >>> sys.getsizeof('aa')-sys.getsizeof('a') 1 >>> sys.getsizeof('=96=96')-sys.getsizeof('=96') 2 That's what the characters really cost. The overhead is fixed. It is, in fact, almost completely insignificant. The storage requirement for a non-ASCII, BMP-only string converges to two bytes per character. ChrisA