[Tutor] what would happen if
lumbricus@gmx.net
lumbricus@gmx.net
Mon, 5 Aug 2002 22:32:49 +0200 (MEST)
>
>
> On Mon, 5 Aug 2002, Sean 'Shaleh' Perry wrote:
>
> >
> > On 05-Aug-2002 Kyle Babich wrote:
> > > Out of curiosity what would happen if I were let something like:
> > >
> > > while 1:
> > > print "hello"
> > >
[ snip ]
> To make the idea more concrete, let's try something else. Say we do
> something like this:
>
> ###
> bathtub = []
> while 1:
> bathtub.append("drip")
> ###
>
> Now, instead of leaving things the way they are, we're accumulating drips
> in a bathtub. That is, we can tell if we've run this loop more than once,
> because the bathtub is growing. This loop is one where we can say that it
> uses more and more resources as it runs. Eventually, if we let things
> continue, we'll overflow the bathtub!
Yes, when *alloc(3) fails, because
your virtual memory (the bathtub) is exhausted,
python bails out with MemoryError as it should be:
$ python eter.py
Traceback (innermost last):
File "eter.py", line 5, in ?
b.append("hello")
MemoryError
$
> This is sorta handwavy, but I hope the idea makes sense. *grin*
>
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
--
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net