Re: [Python-Dev] PATCH: Fast globals/builtins lookups for 2.6

2007-12-27 Thread Armin Rigo
Hi Neil,

On Fri, Nov 30, 2007 at 09:14:04AM -0700, Neil Toronto wrote:
> >> whether 64 bits is necessary. It takes an hour of concerted effort - 
> >> nothing but "module.d = 1; del module.d" for an hour straight - to 
> >> overflow a 32-bit version number. Is anybody going to actually get close 
> >> to doing that in a global namespace?
> >>
> > Of course not. And 640k is as much memory as anyone could reasonably 
> > need ...
> 
> Point taken - forget I asked.

How much time does it take if the loop is in a C extension module, e.g.
like the following?

while (1) { PyDict_SetItem(d, k, v); PyDict_DelItem(d, k); }

How much time would it take the same loop to overflow even the 64-bit
version number?  And how much will *this* take in ten year's time?


A bientot,

Armin
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PATCH: Fast globals/builtins lookups for 2.6

2007-12-27 Thread Daniel Stutzbach
On Dec 27, 2007 4:22 AM, Armin Rigo <[EMAIL PROTECTED]> wrote:
> How much time does it take if the loop is in a C extension module, e.g.
> like the following?
>
> while (1) { PyDict_SetItem(d, k, v); PyDict_DelItem(d, k); }
>
> How much time would it take the same loop to overflow even the 64-bit
> version number?

On a modern computer, more than a century.

> And how much will *this* take in ten year's time?

My rule of thumb is that a tight loop performing 2**32 operations
takes around a minute on a modern computer.  The PyDict operations
presumably take somewhat longer than a few primitive operations, so
this is a good lower bound.

Assuming that processing speed doubles every 1.5 year, we have

(2**64 operations / 2**32 operations per minute / 2**(10 years / 1.5
years per speed doubling))
= 42275935 minutes
= 1.34 years of running that tight loop to get an overflow.

I think 64 bits is pretty safe :-)

-- 
Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises LLC
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com