Serhiy Storchaka added the comment:
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("&")'
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.
----------
nosy: +serhiy.storchaka
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue30011>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com