This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Pickling compiled re patterns
Type: enhancement Stage: patch review
Components: Library (Lib), Regular Expressions Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, gvanrossum, mrabarnett, pitrou, serhiy.storchaka
Priority: normal Keywords: easy, patch

Created on 2014-09-15 08:42 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
re_pickle.patch serhiy.storchaka, 2014-09-15 09:22 review
Messages (2)
msg226905 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-09-15 08:42
Compiled re._compile() is used to reconstruct compiled regular expression pattern. re._compile() is private function and can be removed in (long-term) future. I propose to use re.compile() instead.
msg226928 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2014-09-15 17:25
But who says this isn't intended? I don't know why it was done this way, but the following reasoning might apply: we want to have a stable API for unpickling compiled regexps, but we want to be able to evolve the re.compile() API. Just the fact that '_compile' starts with an underscore doesn't mean that it may involve -- in fact, the fact that it is used by pickles says the opposite. Therefore I think the patch makes things worse (tying the pickle format to the public re.compile() method).

At best we should add a comment to _compile explaining that its API is constrained by pickle backward compatibility.
History
Date User Action Args
2022-04-11 14:58:08adminsetgithub: 66606
2014-09-15 17:25:14gvanrossumsetstatus: open -> closed

nosy: + gvanrossum
messages: + msg226928

resolution: not a bug
2014-09-15 09:22:48serhiy.storchakasetfiles: + re_pickle.patch
keywords: + patch
stage: patch review
2014-09-15 08:42:37serhiy.storchakacreate