Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.057 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'exception.': 0.09; 'subject:Why': 0.09; 'bug': 0.12; "wouldn't": 0.14; 'operation,': 0.16; 'received:74.208.4.195': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'typing': 0.19; 'memory': 0.22; 'header:User-Agent:1': 0.23; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; "i'm": 0.30; 'cap': 0.31; 'ok.': 0.31; 'there.': 0.32; 'probably': 0.32; "we're": 0.32; 'run': 0.32; 'open': 0.33; 'linux': 0.33; 'sense': 0.34; 'maybe': 0.34; 'but': 0.35; 'there': 0.35; 'ubuntu': 0.36; 'doing': 0.36; 'possible': 0.36; 'subject:?': 0.36; 'should': 0.36; 'application': 0.37; 'operating': 0.37; 'to:addr:python-list': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'tell': 0.60; 'more': 0.64; 'received:74.208': 0.68; 'allocation': 0.74; 'fails,': 0.84; 'besides,': 0.93 Date: Sun, 31 Mar 2013 08:43:10 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Why does 1**2**3**4**5 raise a MemoryError? References: <8e43bc87-e822-4bb3-b9ef-ccd489da8bf3@googlegroups.com> <5157e6cc$0$29974$c3e8da3$5496439d@news.astraweb.com> <8276eff6-9e5c-4060-b9e8-94fab606206f@googlegroups.com> In-Reply-To: <8276eff6-9e5c-4060-b9e8-94fab606206f@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:Zt8P8+ItZT2IHGw7BvPmpsqMlDQGyMW9PDhKA7g0dG6 pkKPQK+OcEr6PCUHANIe47gnbZ9T0xEjclevM62a4+4aJbeJba XinGGYfNBn6mF6SdPf0G9YWYTuPCf6aI83ChlFiNlojefBMreP bJ7tCGdptZtPWhS6j66b2dYUeCMtm43KHG24xk0KRTFyLQK+aY jR8ff3xOKrO4k6V2VAFdI0H53L811kPdcNMWJwNFlWN16gA0Lu B4MVPGynqPrGczKqXPSdxApqCx+E8tzFP9iQznpDrpjUhvc4lx 0F0a3ZWjY2TIgLoUWaK8vbR5I+CvzlnZoZMiBV/unqTmeqKqg= = 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364733818 news.xs4all.nl 6920 [2001:888:2000:d::a6]:49870 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:42365 On 03/31/2013 08:07 AM, morphex wrote: > Aha, OK. Thought I found a bug but yeah that makes sense ;) > > While we're on the subject, wouldn't it be nice to have some cap there so that it isn't possible to more or less block the system with large exponentiation? > There's an assumption there. The Operating System should defend itself against starvation by any single process. Besides, there are many ways for a process to run out of memory, and exponentiation is probably the least likely of them. In general, an application cannot tell whether a particular memory allocation will succeed or not without actually trying the allocation. If it fails, you get the exception. I'm typing this while a terminal is open doing the particular operation, and the system doesn't seem in the least sluggish. Currently the memory used is at 10gig, and while there are some pauses in my typing, the system has not died. This is on Linux Ubuntu 12.04. At 15gig, there are some blockages, of maybe 5 secs each. -- DaveA