Skip to content

Commit 91dc1d7

Browse files
authored
Merge pull request #119 from gitpushdashf/master
Pickle REGEX_PATTERNS
2 parents 91148b9 + b15191c commit 91dc1d7

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

fastjsonschema/generator.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from collections import OrderedDict
22
import re
3+
import pickle
34

45
from .exceptions import JsonSchemaValueException, JsonSchemaDefinitionException
56
from .indent import indent
@@ -100,15 +101,12 @@ def global_state_code(self):
100101
'',
101102
'',
102103
])
103-
regexs = ['"{}": re.compile(r"{}")'.format(key, value.pattern) for key, value in self._compile_regexps.items()]
104104
return '\n'.join(self._extra_imports_lines + [
105-
'import re',
105+
'import re, pickle',
106106
'from fastjsonschema import JsonSchemaValueException',
107107
'',
108108
'',
109-
'REGEX_PATTERNS = {',
110-
' ' + ',\n '.join(regexs),
111-
'}',
109+
'REGEX_PATTERNS = pickle.loads(' + str(pickle.dumps(self._compile_regexps)) + ')',
112110
'',
113111
])
114112

0 commit comments

Comments
 (0)