This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients ale2017, ezio.melotti, serhiy.storchaka
Date 2017-04-15.06:12:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1492236741.36.0.0135431478162.issue30011@psf.upfronthosting.co.za>
In-reply-to
Content
There is nothing wrong with building entitydefs multiple times since the result is same. An alternative is using locking, but this is more cumbersome solution. And building entitydefs is much faster than importing the threading module.

$ ./python -m timeit -s 'from HTMLParser import HTMLParser; p = HTMLParser()' -- 'HTMLParser.entitydefs = None; p.unescape("&amp;")'
1000 loops, best of 3: 412 usec per loop

$ ./python -m timeit -s 'import sys; m = sys.modules.copy()' -- 'import threading; sys.modules.clear(); sys.modules.update(m)'
100 loops, best of 3: 5.43 msec per loop

Current solution is faster in single-thread case, correct likely fast enough in multi-thread case.
History
Date User Action Args
2017-04-15 06:12:21serhiy.storchakasetrecipients: + serhiy.storchaka, ezio.melotti, ale2017
2017-04-15 06:12:21serhiy.storchakasetmessageid: <1492236741.36.0.0135431478162.issue30011@psf.upfronthosting.co.za>
2017-04-15 06:12:21serhiy.storchakalinkissue30011 messages
2017-04-15 06:12:20serhiy.storchakacreate