Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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; 'python,': 0.02; 'received:209.85.223': 0.03; '(even': 0.05; 'interpreter': 0.05; 'subject:Python': 0.06; '64-bit': 0.07; 'memory.': 0.07; 'odd': 0.07; 'though:': 0.07; 'string': 0.09; '22,': 0.09; '32-bit': 0.09; 'integers': 0.09; 'pep': 0.09; 'subject:How': 0.10; 'python': 0.11; 'jan': 0.12; 'behave': 0.16; 'behavior,': 0.16; 'java.': 0.16; 'limit.': 0.16; 'minus': 0.16; 'stuff.': 0.16; 'wrote:': 0.18; "python's": 0.19; 'thu,': 0.19; 'seems': 0.21; 'memory': 0.22; 'to:name:python-list@python.org': 0.22; 'creating': 0.23; 'header:User-Agent:1': 0.23; 'bytes': 0.24; 'java': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'raise': 0.29; 'characters': 0.30; "i'm": 0.30; 'gives': 0.31; '(maybe': 0.31; 'another': 0.32; 'guess': 0.33; 'received:209.85': 0.35; 'beyond': 0.35; 'no,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'shows': 0.36; 'useful': 0.36; 'received:209': 0.37; 'subject:new': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'subject:" ': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'length': 0.61; 'new': 0.61; 'simply': 0.61; 'back': 0.62; "you'll": 0.62; 'watching': 0.68; 'limit': 0.70; 'allocation': 0.74; 'increase': 0.74; '2015': 0.84; 'usage.': 0.84 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=RQJpNXDZE9M5f33t8alMM/KUptZIXbqAIXYqzs0DBVA=; b=f8jl4NnuYXI/UcnlmGmhV/07WrzWdn8BrrU1kxvgyOFQtUvimHQj/Ns131dxonP5Kn +1/bdolPP0szWZn0d3BntS9v+Yq9nBxaDiJcUHbIKkqacbxzGo4ea3h1StKAFy+PYmxu xo55OXh3AKgSd97lfliR1wR3+QF0zGLv3sStfFucD0jtKQp/5+XfNfSWOiwj9Ty4pV+h ciNeTj9C9uVRVlgvGgZK4PNNZ5bj6coU7BSbi7zr6JdjMezlU4eKhJ6+EIWqSM/yV1zF sNlcOEoW+EPUg+/gao8K7d/qRvZxI/wTcC4STZU1ZhmZtEopL36Dlxq5pTs3MjV+Az7q 2cFQ== X-Gm-Message-State: ALoCoQnP3/PfXLyiEjDh1VvzkouPbo+SEc12c14h6sqeC/qZ8ySfqaOygTWXNjzeczOgm9DZDFwjJN2DiVzEXvk5eA9wZAAR2UzFidgfdmbd66an/1BWv6SJCnSAggu1ZuYcRZy88iLC X-Received: by 10.50.108.83 with SMTP id hi19mr37847863igb.8.1421876779591; Wed, 21 Jan 2015 13:46:19 -0800 (PST) X-Received: by 10.50.108.83 with SMTP id hi19mr37847854igb.8.1421876779512; Wed, 21 Jan 2015 13:46:19 -0800 (PST) From: Matthew Ruffalo X-Google-Original-From: Matthew Ruffalo Date: Wed, 21 Jan 2015 16:46:18 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: "python-list@python.org" Subject: Re: How to "wow" someone new to Python References: <82qvba51o427s4m63agk6ghekm0btg81on@4ax.com> <54bfedf5$0$2876$e4fe514c@news.xs4all.nl> <54C01802.7020202@case.edu> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu) 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421877166 news.xs4all.nl 2903 [2001:888:2000:d::a6]:54951 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:84145 On 01/21/2015 04:26 PM, Chris Angelico wrote: > On Thu, Jan 22, 2015 at 8:20 AM, Matthew Ruffalo wrote= : >> Yes, length-unlimited strings are *extremely* useful in some >> applications. I remember bitterly cursing Java's string length limit o= f >> 2 ** 31 (maybe - 1) on multiple occasions. Python's strings seem to >> behave like integers in that their size is limited only by available m= emory. > Hmm, I don't know that you'll get much beyond 2**31 characters (even > all-ASCII characters in PEP 393) on a 32-bit Python, simply because > "available memory" is capped at 2**32 bytes minus other stuff. You'd > need a 64-bit Python to do that, and I would guess a 64-bit Java would > also raise the limit. > > ChrisA No, Java's String.length returns an int and Strings are limited to ~2 ** 31 characters even in 64-bit Java. 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. MMR...