cpython: db5f2b74e369 (original) (raw)
Mercurial > cpython
changeset 84481:db5f2b74e369
#18020: improve html.escape speed by an order of magnitude. Patch by Matt Bryant. [#18020]
Ezio Melotti ezio.melotti@gmail.com | |
---|---|
date | Sun, 07 Jul 2013 11:11:24 +0200 |
parents | d7a59e6f48df |
children | 2ab2a2bfea49 |
files | Lib/html/__init__.py Misc/ACKS Misc/NEWS |
diffstat | 3 files changed, 10 insertions(+), 7 deletions(-)[+] [-] Lib/html/__init__.py 13 Misc/ACKS 1 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/html/init.py +++ b/Lib/html/init.py @@ -2,11 +2,6 @@ General functions for HTML manipulation. """ - -_escape_map = {ord('&'): '&', ord('<'): '<', ord('>'): '>'} -_escape_map_full = {ord('&'): '&', ord('<'): '<', ord('>'): '>',
ord('"'): '"', ord('\''): '''}[](#l1.10)
NB: this is a candidate for a bytes/string polymorphic interface
def escape(s, quote=True): @@ -16,6 +11,10 @@ def escape(s, quote=True): characters, both double quote (") and single quote (') characters are also translated. """
- s = s.replace("&", "&") # Must be done first
- s = s.replace("<", "<")
- s = s.replace(">", ">") if quote:
--- a/Misc/ACKS +++ b/Misc/ACKS @@ -172,6 +172,7 @@ Dave Brueck Francisco Martín Brugué Ian Bruntlett Floris Bruynooghe +Matt Bryant Stan Bubrouski Erik de Bueger Jan-Hein Bührman
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -142,6 +142,9 @@ Core and Builtins Library ------- +- Issue #18020: improve html.escape speed by an order of magnitude.