Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82899
| References | <mailman.17176.1419410409.18130.python-list@python.org> <549aa1f9$0$12981$c3e8da3$5496439d@news.astraweb.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2014-12-24 09:39 -0700 |
| Subject | Re: question on string object handling in Python 2.7.8 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17187.1419439221.18130.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
On Wed, Dec 24, 2014 at 4:22 AM, Steven D'Aprano < steve+comp.lang.python@pearwood.info> wrote: > What happens here is that you time a piece of code to: > > - Build a large list containing 100 million individual int objects. Each int > object has to be allocated at run time, as does the list. Each int object > is about 12 bytes in size. Note to the OP: since you're using Python 2 you would do better to loop over an xrange object instead of a range. xrange produces an iterator over the desired range without needing to construct a single list containing all of them. They would all still need to be allocated, but not all at once, and memory could be reused.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
question on string object handling in Python 2.7.8 Dave Tian <dave.jing.tian@gmail.com> - 2014-12-23 20:28 -0500
Re: question on string object handling in Python 2.7.8 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-24 22:22 +1100
Re: question on string object handling in Python 2.7.8 Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-24 09:39 -0700
Re: question on string object handling in Python 2.7.8 Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-12-25 17:23 +1300
Re: question on string object handling in Python 2.7.8 Denis McMahon <denismfmcmahon@gmail.com> - 2014-12-25 16:34 +0000
csiph-web