[Patches] [ python-Patches-977553 ] Speed up EnumKey call

SourceForge.net noreply at sourceforge.net
Wed Jul 14 17:54:48 CEST 2004


Patches item #977553, was opened at 2004-06-22 17:22
Message generated for change (Comment added) made by theller
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=977553&group_id=5470

Category: Windows
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Garth Bushell (garth42)
Assigned to: Nobody/Anonymous (nobody)
Summary: Speed up EnumKey call

Initial Comment:
This patch removes the RegQueryInfoKey call and
replaces it with a call to EnumKeyEx. This greatly
speeds up this call. 

The script below times 

python 2.3              5531 89.7130000591
python 2.4 +patch   5531 0.0469999313354

start = time.time()
i = 0
try:
  while 1:
    _winreg.EnumKey(_winreg.HKEY_CLASSES_ROOT, i)
    i += 1
except WindowsError:
  pass
print i, time.time() - start


----------------------------------------------------------------------

>Comment By: Thomas Heller (theller)
Date: 2004-07-14 17:54

Message:
Logged In: YES 
user_id=11105

I'm curious: Why did you replace RegEnumKey with
RegEnumKeyEx? Are there any advantages of the latter?

----------------------------------------------------------------------

Comment By: Mike Mangino (mmangino)
Date: 2004-07-14 16:12

Message:
Logged In: YES 
user_id=74879

This looks good to me, but I think the buffer size is off by
one. I read the SDK to say tha they key can be 255
characters. That means you need to allocate 256 characters
to allow for the null terminator. Could you create a test
case for a max length registry key?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=977553&group_id=5470


More information about the Patches mailing list