Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'interpreter': 0.05; 'subject:Python': 0.06; '64-bit': 0.07; 'odd': 0.07; 'though:': 0.07; 'string': 0.09; '22,': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'jan': 0.12; 'stored': 0.12; 'behavior,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'integer.': 0.16; 'java.': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'seems': 0.21; 'memory': 0.22; '(in': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'file.': 0.24; 'cc:2**0': 0.24; 'header :In-Reply-To:1': 0.27; 'am,': 0.29; 'characters': 0.30; 'have,': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '(which': 0.31; 'gives': 0.31; 'file': 0.32; 'weeks': 0.32; 'another': 0.32; 'implemented': 0.33; 'no,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'shows': 0.36; 'subject:new': 0.38; 'depends': 0.38; 'subject:" ': 0.39; 'how': 0.40; 'even': 0.60; 'ago.': 0.61; 'length': 0.61; 'new': 0.61; "you're": 0.61; 'back': 0.62; 'watching': 0.68; 'physical': 0.72; 'allocation': 0.74; 'increase': 0.74; '2015': 0.84; 'believe,': 0.84; "it'd": 0.84; 'usage.': 0.84; 'to:none': 0.92 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:cc :content-type; bh=saSYxU5V6sIXAFbDX53uKDL3yx7mekan9yzm/OA9W4k=; b=uS6QeSJXfJdTBJiWiMFrNytFgbzTuxP4/TsdkoN5eoIqTVSGCXmqSKWs9xa7FJsh3H xLYv+ZH04wX8XLI4SDMi2gHB0BjHdPSOOZ1al0E+PaRA1gcqysGH+pvbsyHy2NsaPOi+ uGIealFqiWmNlKGYeakly0lmgzgIcpQUzATTxor2O6oZjs2ofvtIO45nROPFDXCk1CGq +QXE5mW31KeCIM5T1Fr7ORRa6LpJO3xUNG7FpUANE6B88VkdcRh8ZaM3E/O1wr/SK3bw J4T9qqBXxXJZ2Ir6idCqdy1aisn/b0ENK4qLFVdtPZvHNzZWbzZcgOG8rv7Yjzf3ZoRj Ga5Q== MIME-Version: 1.0 X-Received: by 10.140.97.203 with SMTP id m69mr43660135qge.39.1421878954952; Wed, 21 Jan 2015 14:22:34 -0800 (PST) In-Reply-To: <54C01E2A.3040602@case.edu> References: <82qvba51o427s4m63agk6ghekm0btg81on@4ax.com> <54bfedf5$0$2876$e4fe514c@news.xs4all.nl> <54C01802.7020202@case.edu> <54C01E2A.3040602@case.edu> Date: Thu, 22 Jan 2015 09:22:34 +1100 Subject: Re: How to "wow" someone new to Python From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421878963 news.xs4all.nl 2912 [2001:888:2000:d::a6]:39335 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:84147 On Thu, Jan 22, 2015 at 8:46 AM, Matthew Ruffalo wrote: > No, Java's String.length returns an int and Strings are limited to ~2 ** > 31 characters even in 64-bit Java. Huh, annoying. In Python, the length of a string (in characters) is stored in a Py_ssize_t (if I recall correctly), which is, I believe, a pointer-sized integer. So it'd be 64-bit on a 64-bit build. > I do seem to have encountered some strange behavior, though: creating > very large strings with str.__mul__ seems to enter an allocation loop in > Python 3.4. With a single-character string 's', I can create the > following new strings quickly: > > s * 2 ** 33 > s * 2 ** 34 > s * 2 ** 35 > s * 2 ** 36 > > but s * 2 ** 38 shows some odd memory usage. I'm watching the memory > usage of a Python process steadily increase to 256GB, drop to a few MB, > climb back to 256GB, drop to a few MB, and so on. It takes a half-dozen > cycles of allocation and deallocation before the interactive interpreter > gives me another prompt. That sounds like you're blooping through your page file. The exact behaviour will depend on how much physical memory you have, how your page file is implemented (which depends on your OS), the phase of the moon, and what you had for breakfast three weeks ago. ChrisA