STINNER Victor added the comment:
> Aren't Python strings immutable?
Yes. But the re module supports more types than just str and bytes. For
example, bytearray is also accepted:
>>> re.match(b'^abc', b'abc')
<_sre.SRE_Match object; span=(0, 3), match=b'abc'>
>>> re.match(b'^abc', bytearray(b'a
Evgeny Kapun added the comment:
Aren't Python strings immutable?
Also, match functions still permit execution of signal handlers, which can
execute any Python code.
If GIL is needed during matching, can it be released temporarily to permit
thread switching?
--
__
STINNER Victor added the comment:
Supporting to release the GIL would require to redesign the _sre module.
For example, the getstring() gets a "view" of a Python string, it doesn't copy
the string. So we must hold the GIL, otherwise the Python string can be
modified by other threads. Copying a
New submission from Evgeny Kapun:
Looks like function in re module (match, fullmatch and so on) don't release
GIL, even though these operations can take much time. As a result, other
threads can't run while a pattern is being matched, and thread switching
doesn't happen as well.
--
co