Comments on Version 2, Draft Pep for Deprecating Builtins

Jeff Epler jepler at unpythonic.net
Thu May 9 15:22:43 EDT 2002


On Thu, May 09, 2002 at 06:30:36PM +0000, Huaiyu Zhu wrote:
> I don't see the reason to prevent 2**2002.

$ time python2.3 -c '2**2**20'
86.28user 0.40system 1:36.95elapsed 89%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (304major+300minor)pagefaults 0swaps
... and AFAIK that's with the GIL held, so it means anybody who can
r_eval an arbitrary string blocks your entire application for an
arbitrary amount of time (or until the intermediate result no longer
fits in RAM)

Or try
$ time python2.3 -c '[[0] * 2**x for x in range(15, 31)]'
Traceback (most recent call last):
  File "<string>", line 1, in ?
MemoryError
Command exited with non-zero status 1
6.76user 2.69system 1:02.34elapsed 15%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (38459major+97990minor)pagefaults 32247swaps
... I thrashed the machine pretty good for a minute.  I could have
thrashed it for longer if I'd tried.


> But if there is such a reason,
> maybe one should tweak r_eval to handle it?

r_eval doesn't perform this level of inspection of code.
> 
> Huaiyu
> -- 
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list