Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Unreasonable memory usage under linux with a simple loop

Reply
Thread Tools

Unreasonable memory usage under linux with a simple loop

 
 
ming_cuhk
Guest
Posts: n/a
 
      01-02-2009
Hi all, I'm new to here and python.
When I tried the code below to test python's speed...
I found that python use more than 1.5G memory to run this and cost
several minutes.... And this happened only under my linux os. Both
jython and python... Is there something wrong with python under linux
or my code?
Thanks!

a = 0
for i in range(100000000):
a = a + 1
print a


 
Reply With Quote
 
 
 
 
Michele Simionato
Guest
Posts: n/a
 
      01-02-2009
On Jan 2, 4:45*pm, ming_cuhk <(E-Mail Removed)> wrote:
> Hi all, I'm new to here and python.
> When I tried the code below to test python's speed...
> I found that python use more than 1.5G memory to run this and cost
> several minutes.... And this happened only under my linux os. Both
> jython and python... *Is there something wrong with python under linux
> or my code?
> Thanks!
>
> a = 0
> for i in range(100000000):
> * * a = a + 1
> print a


This is fixed in Python 3.0. In older Python versions, use
xrange instead of range.
 
Reply With Quote
 
 
 
 
ming_cuhk
Guest
Posts: n/a
 
      01-02-2009
On Jan 2, 11:49*pm, Michele Simionato <(E-Mail Removed)>
wrote:
> On Jan 2, 4:45*pm, ming_cuhk <(E-Mail Removed)> wrote:
>
> > Hi all, I'm new to here and python.
> > When I tried the code below to test python's speed...
> > I found that python use more than 1.5G memory to run this and cost
> > several minutes.... And this happened only under my linux os. Both
> > jython and python... *Is there something wrong with python under linux
> > or my code?
> > Thanks!

>
> > a = 0
> > for i in range(100000000):
> > * * a = a + 1
> > print a

>
> This is fixed in Python 3.0. In older Python versions, use
> xrange instead of range.


Thanks! But this isn't appear in MAC and Windows~?
 
Reply With Quote
 
Michele Simionato
Guest
Posts: n/a
 
      01-02-2009
On Jan 2, 4:50*pm, ming_cuhk <(E-Mail Removed)> wrote:
> On Jan 2, 11:49*pm, Michele Simionato <(E-Mail Removed)>
> wrote:
>
>
>
> > On Jan 2, 4:45*pm, ming_cuhk <(E-Mail Removed)> wrote:

>
> > > Hi all, I'm new to here and python.
> > > When I tried the code below to test python's speed...
> > > I found that python use more than 1.5G memory to run this and cost
> > > several minutes.... And this happened only under my linux os. Both
> > > jython and python... *Is there something wrong with python under linux
> > > or my code?
> > > Thanks!

>
> > > a = 0
> > > for i in range(100000000):
> > > * * a = a + 1
> > > print a

>
> > This is fixed in Python 3.0. In older Python versions, use
> > xrange instead of range.

>
> Thanks! But this isn't appear in MAC and Windows~?


It should happen on all platforms, since you are building
a list with 100 millions of integers, which is quite large,
especially if you are running on a 64 bit OS.
 
Reply With Quote
 
ming_cuhk
Guest
Posts: n/a
 
      01-02-2009
On Jan 2, 11:52*pm, Michele Simionato <(E-Mail Removed)>
wrote:
> On Jan 2, 4:50*pm, ming_cuhk <(E-Mail Removed)> wrote:
>
>
>
> > On Jan 2, 11:49*pm, Michele Simionato <(E-Mail Removed)>
> > wrote:

>
> > > On Jan 2, 4:45*pm, ming_cuhk <(E-Mail Removed)> wrote:

>
> > > > Hi all, I'm new to here and python.
> > > > When I tried the code below to test python's speed...
> > > > I found that python use more than 1.5G memory to run this and cost
> > > > several minutes.... And this happened only under my linux os. Both
> > > > jython and python... *Is there something wrong with python under linux
> > > > or my code?
> > > > Thanks!

>
> > > > a = 0
> > > > for i in range(100000000):
> > > > * * a = a + 1
> > > > print a

>
> > > This is fixed in Python 3.0. In older Python versions, use
> > > xrange instead of range.

>
> > Thanks! But this isn't appear in MAC and Windows~?

>
> It should happen on all platforms, since you are building
> a list with 100 millions of integers, which is quite large,
> especially if you are running on a 64 bit OS.


You are right...Thanks.... Since my MAC have too much RAM..I didn't
notice it....
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
ridicuously unreasonable Paul C++ 8 02-24-2011 05:40 PM
Question about unreasonable slowness allenjo5@mail.northgrum.com Python 10 11-21-2006 08:22 PM
Warranty Issues - Am I being unreasonable?. EMB NZ Computing 23 08-17-2005 12:03 AM
Unreasonable Reboots =?Utf-8?B?Z3Rw?= Wireless Networking 3 10-14-2004 06:45 PM



Advertisments