[issue23690] re functions never release GIL

2015-03-17 Thread STINNER Victor
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

[issue23690] re functions never release GIL

2015-03-17 Thread Evgeny Kapun
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? -- __

[issue23690] re functions never release GIL

2015-03-17 Thread STINNER Victor
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

[issue23690] re functions never release GIL

2015-03-17 Thread Evgeny Kapun
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