[Python-Dev] mimetypes and _winreg

Thomas Heller theller at python.net
Fri Jun 11 18:20:55 EDT 2004


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




More information about the Python-Dev mailing list