[Python-Dev] mimetypes and _winreg
Garth
garth at garthy.com
Sat Jun 12 15:16:20 EDT 2004
Thomas Heller wrote:
>Mike Brown <mike at skew.org> writes:
>
>
>
>>I thought it would be nice to try to improve the mimetypes module by having
>>it, on Windows, query the Registry to get the mapping of filename extensions
>>to media types, since the mimetypes code currently just blindly checks
>>posix-specific paths for httpd-style mapping files. However, it seems that the
>>way to get mappings from the Windows registry is excessively slow in Python.
>>
>>I'm told that the reason has to do with the limited subset of APIs that are
>>exposed in the _winreg module. I think it is that EnumKey(key, index) is
>>querying for the entire list of subkeys for the given key every time you call
>>it. Or something. Whatever the situation is, the code I tried below is way
>>slower than I think it ought to be.
>>
>>Does anyone have any suggestions (besides "write it in C")? Could _winreg
>>possibly be improved to provide an iterator or better interface to get the
>>subkeys? (or certain ones? There are a lot of keys under HKEY_CLASSES_ROOT,
>>and I only need the ones that start with a period).
>>
>>
>
>See this post I made some time ago:
><http://mail.python.org/pipermail/python-dev/2004-January/042198.html>
>
>
>
>>Should I file this as a feature request?
>>
>>
>
>If you still think it should be changed in the core, you should work on
>a patch.
>
>Thomas
>
>
>
I could file a patch if no one else is looking at it. The solution would
be to use
RegEnumKeyEx and remove RegQueryInfoKey. This loses compatability with win16 which
I guess is ok.
Garth
More information about the Python-Dev
mailing list