Author serhiy.storchaka
Recipients Abel.Farias, eric.araujo, eric.snow, ezio.melotti, georg.brandl, gvanrossum, mrabarnett, py.user, serhiy.storchaka, vstinner
Date 2014-11-01.15:27:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <3566304.kqLxnvgyWk@raxxla>
In-reply-to <>
Here are two patches which implement two alternative solutions. They are based on regex code.

Dict copying patch matches current regex behavior and needs modifying other code to avoid small slowdown. Artificial example:

$ ./python -m timeit -s 'import re; n = 100; m = re.match("".join("(?P<g%d>.)" % g for g in range(n)), "x" * n); t = ",".join(r"\g<g%d>" % g for g in range(n))' -- 'm.expand(t)'

Without patch: 7.48 msec per loop
With re_groupindex_copy.patch but without modifying _expand: 9.61 msec per loop
With re_groupindex_copy.patch and with modifying _expand: 7.41 msec per loop

While stdlib code can be modified, this patch can cause small slowdown of some third-party code.

Dict proxying patch has no performance effect, but it is slightly less compatible. Some code can accept dict but not dict-like object.
File name Uploaded
re_groupindex_copy.patch serhiy.storchaka, 2014-11-01.15:27:01
re_groupindex_proxy.patch serhiy.storchaka, 2014-11-01.15:27:02
Date User Action Args
2014-11-01 15:27:02serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, georg.brandl, vstinner, ezio.melotti, eric.araujo, mrabarnett, py.user, eric.snow, Abel.Farias
2014-11-01 15:27:02serhiy.storchakalinkissue14260 messages
2014-11-01 15:27:02serhiy.storchakacreate