[New-bugs-announce] [issue35292] Make SimpleHTTPRequestHandler load mimetypes lazily

Steve Dower report at bugs.python.org
Wed Nov 21 12:41:40 EST 2018

New submission from Steve Dower <steve.dower at python.org>:

Importing http.server triggers mimetypes.init(), which can be fairly expensive on Windows (and potentially other platforms?) due to having to enumerate a lot of registry keys.

Instead, SimpleHTTPRequestHandler.extensions_map can be a dict with just its default values in lib/http/server.py and the first call to guess_type() can initialize mimetypes if necessary.

We should check whether people read from SimpleHTTPRequestHandler.extensions_map directly before calling guess_type(), and decide how quickly we can make the change. My gut feeling is we will be okay to make this in the next release but probably shouldn't backport it.

components: Library (Lib), Windows
keywords: easy
messages: 330212
nosy: paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
stage: needs patch
status: open
title: Make SimpleHTTPRequestHandler load mimetypes lazily
type: performance
versions: Python 3.8

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list