Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #84145

Re: How to "wow" someone new to Python

From Matthew Ruffalo <mmr15@case.edu>
Date 2015-01-21 16:46 -0500
Subject Re: How to "wow" someone new to Python
References (1 earlier) <82qvba51o427s4m63agk6ghekm0btg81on@4ax.com> <54bfedf5$0$2876$e4fe514c@news.xs4all.nl> <CAPTjJmrZ42_bVHiHy2pnGUOjkmuUCimkqSDDL7fmTg-u_vJxuQ@mail.gmail.com> <54C01802.7020202@case.edu> <CAPTjJmo-ZKpQzn7dodM9SnvJ_HcKMwNhP6rpXczkoB-qQoAJhw@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.17924.1421877166.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 01/21/2015 04:26 PM, Chris Angelico wrote:
> On Thu, Jan 22, 2015 at 8:20 AM, Matthew Ruffalo <mmr15@case.edu> wrote:
>> Yes, length-unlimited strings are *extremely* useful in some
>> applications. I remember bitterly cursing Java's string length limit of
>> 2 ** 31 (maybe - 1) on multiple occasions. Python's strings seem to
>> behave like integers in that their size is limited only by available memory.
> 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...

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to "wow" someone new to Python Chris Angelico <rosuav@gmail.com> - 2015-01-17 02:03 +1100
  Re: How to "wow" someone new to Python Marko Rauhamaa <marko@pacujo.net> - 2015-01-16 17:20 +0200
  Re: How to "wow" someone new to Python Rustom Mody <rustompmody@gmail.com> - 2015-01-16 09:16 -0800
  Re: How to "wow" someone new to Python alex23 <wuwei23@gmail.com> - 2015-01-19 16:19 +1000
  Re: How to "wow" someone new to Python wxjmfauth@gmail.com - 2015-01-21 07:15 -0800
  Re: How to "wow" someone new to Python Steve Hayes <hayesstw@telkomsa.net> - 2015-01-21 19:59 +0200
    Re: How to "wow" someone new to Python Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2015-01-21 19:20 +0100
      Re: How to "wow" someone new to Python Chris Angelico <rosuav@gmail.com> - 2015-01-22 06:06 +1100
        Re: How to "wow" someone new to Python André Roberge <andre.roberge@gmail.com> - 2015-01-21 11:20 -0800
        Re: How to "wow" someone new to Python Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2015-01-22 00:46 +0100
      Re: How to "wow" someone new to Python Matthew Ruffalo <mmr15@case.edu> - 2015-01-21 16:20 -0500
      Re: How to "wow" someone new to Python Chris Angelico <rosuav@gmail.com> - 2015-01-22 08:26 +1100
        Re: How to "wow" someone new to Python Alan Bawden <alan@scooby-doo.csail.mit.edu> - 2015-01-21 16:44 -0500
          Re: How to "wow" someone new to Python Alan Bawden <alan@scooby-doo.csail.mit.edu> - 2015-01-21 16:52 -0500
            Re: How to "wow" someone new to Python Paul Rubin <no.email@nospam.invalid> - 2015-01-21 14:35 -0800
            Re: How to "wow" someone new to Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-22 15:51 +1100
          Re: How to "wow" someone new to Python Mario Figueiredo <marfig@gmail.com> - 2015-01-21 23:13 +0100
      Re: How to "wow" someone new to Python Matthew Ruffalo <mmr15@case.edu> - 2015-01-21 16:46 -0500
      Re: How to "wow" someone new to Python Chris Angelico <rosuav@gmail.com> - 2015-01-22 09:22 +1100
  Re: How to "wow" someone new to Python André Roberge <andre.roberge@gmail.com> - 2015-01-21 10:34 -0800
  Re: How to "wow" someone new to Python Mario Figueiredo <marfig@gmail.com> - 2015-01-21 19:05 +0000
    Re: How to "wow" someone new to Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-22 15:39 +1100
      Re: How to "wow" someone new to Python Grant Edwards <invalid@invalid.invalid> - 2015-01-23 00:09 +0000

csiph-web