PyPcre 0.2.11__tar.gz → 0.2.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pypcre-0.2.11 → pypcre-0.2.12}/PKG-INFO +1 -1
- {pypcre-0.2.11 → pypcre-0.2.12}/PyPcre.egg-info/PKG-INFO +1 -1
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre/cache.py +0 -9
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre/pcre.py +25 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre_ext/pattern_cache.c +0 -22
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre_ext/pcre2.c +0 -5
- {pypcre-0.2.11 → pypcre-0.2.12}/pyproject.toml +1 -1
- {pypcre-0.2.11 → pypcre-0.2.12}/LICENSE +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/MANIFEST.in +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/PyPcre.egg-info/SOURCES.txt +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/PyPcre.egg-info/dependency_links.txt +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/PyPcre.egg-info/top_level.txt +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/README.md +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre/__init__.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre/error.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre/flags.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre/re_compat.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre/threads.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre_ext/atomic_compat.h +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre_ext/cache.c +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre_ext/error.c +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre_ext/flag.c +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre_ext/jit_support.c +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre_ext/memory.c +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre_ext/pcre2.h +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre_ext/pcre2_module.h +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre_ext/string_helpers.c +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/pcre_ext/util.c +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/setup.cfg +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/setup.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/setup_utils.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_accuracy.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_api_parity.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_basic.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_bench_string.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_benchmark.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_bytes.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_cache.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_clobber.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_clobber_thread.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_core.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_errors.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_flags.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_jit.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_memory.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_module.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_pattern.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_setup_utils_multiarch.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_simd.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_threaded_backend.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_transformers_regex.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_utf8.py +0 -0
- {pypcre-0.2.11 → pypcre-0.2.12}/tests/test_version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyPcre
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.12
|
|
4
4
|
Summary: Modern, GIL-friendly, Fast Python bindings for PCRE2 with auto caching and JIT of compiled patterns.
|
|
5
5
|
Author-email: ModelCloud <qubitium@modelcloud.ai>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyPcre
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.12
|
|
4
4
|
Summary: Modern, GIL-friendly, Fast Python bindings for PCRE2 with auto caching and JIT of compiled patterns.
|
|
5
5
|
Author-email: ModelCloud <qubitium@modelcloud.ai>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -48,13 +48,6 @@ class _GlobalCacheState:
|
|
|
48
48
|
_THREAD_LOCAL = _ThreadCacheState()
|
|
49
49
|
_GLOBAL_STATE = _GlobalCacheState()
|
|
50
50
|
_CACHE_STRATEGY = _CacheStrategy.THREAD_LOCAL
|
|
51
|
-
_CACHE_STRATEGY_LOCKED = False
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def _lock_cache_strategy() -> None:
|
|
55
|
-
global _CACHE_STRATEGY_LOCKED
|
|
56
|
-
if not _CACHE_STRATEGY_LOCKED:
|
|
57
|
-
_CACHE_STRATEGY_LOCKED = True
|
|
58
51
|
|
|
59
52
|
|
|
60
53
|
def _normalize_strategy(value: str) -> _CacheStrategy:
|
|
@@ -178,8 +171,6 @@ def cached_compile(
|
|
|
178
171
|
) -> T:
|
|
179
172
|
"""Compile *pattern* with *flags*, caching wrapper results when hashable."""
|
|
180
173
|
|
|
181
|
-
_lock_cache_strategy()
|
|
182
|
-
|
|
183
174
|
if _CACHE_STRATEGY is _CacheStrategy.THREAD_LOCAL:
|
|
184
175
|
return _cached_compile_thread_local(pattern, flags, wrapper, jit=jit)
|
|
185
176
|
return _cached_compile_global(pattern, flags, wrapper, jit=jit)
|
|
@@ -473,6 +473,31 @@ class Pattern:
|
|
|
473
473
|
|
|
474
474
|
|
|
475
475
|
def compile(pattern: Any, flags: FlagInput = 0) -> Pattern:
|
|
476
|
+
# Fast path for the dominant shape: compile(pattern) with default flags.
|
|
477
|
+
if flags == 0:
|
|
478
|
+
if isinstance(pattern, Pattern):
|
|
479
|
+
return pattern
|
|
480
|
+
|
|
481
|
+
if isinstance(pattern, _CPattern):
|
|
482
|
+
wrapper = Pattern(pattern)
|
|
483
|
+
if get_thread_default():
|
|
484
|
+
wrapper.enable_auto_threads()
|
|
485
|
+
else:
|
|
486
|
+
wrapper.disable_threads()
|
|
487
|
+
return wrapper
|
|
488
|
+
|
|
489
|
+
adjusted_pattern = _apply_regex_compat(pattern, bool(_DEFAULT_COMPAT_REGEX))
|
|
490
|
+
if isinstance(adjusted_pattern, str):
|
|
491
|
+
native_flags = _pcre2.PCRE2_UTF | _pcre2.PCRE2_UCP
|
|
492
|
+
else:
|
|
493
|
+
native_flags = 0
|
|
494
|
+
compiled = cached_compile(adjusted_pattern, native_flags, Pattern, jit=_DEFAULT_JIT)
|
|
495
|
+
if get_thread_default():
|
|
496
|
+
compiled.enable_auto_threads()
|
|
497
|
+
else:
|
|
498
|
+
compiled.disable_threads()
|
|
499
|
+
return compiled
|
|
500
|
+
|
|
476
501
|
resolved_flags = _normalise_flags(flags)
|
|
477
502
|
threads_requested = bool(resolved_flags & THREADS)
|
|
478
503
|
no_threads_requested = bool(resolved_flags & NO_THREADS)
|
|
@@ -211,27 +211,6 @@ pattern_cache_teardown(void)
|
|
|
211
211
|
atomic_store_explicit(&pattern_cache_global_mode, 0, memory_order_release);
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
static void
|
|
215
|
-
pattern_cache_touch(PatternCacheState *state, PyObject *cache_key)
|
|
216
|
-
{
|
|
217
|
-
if (state->order == NULL) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
Py_ssize_t idx = PySequence_Index(state->order, cache_key);
|
|
221
|
-
if (idx >= 0) {
|
|
222
|
-
if (PySequence_DelItem(state->order, idx) < 0) {
|
|
223
|
-
PyErr_Clear();
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
} else if (PyErr_Occurred()) {
|
|
227
|
-
PyErr_Clear();
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
if (PyList_Append(state->order, cache_key) < 0) {
|
|
231
|
-
PyErr_Clear();
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
214
|
int
|
|
236
215
|
pattern_cache_lookup(PyObject *cache_key, PatternObject **out_pattern)
|
|
237
216
|
{
|
|
@@ -256,7 +235,6 @@ pattern_cache_lookup(PyObject *cache_key, PatternObject **out_pattern)
|
|
|
256
235
|
if (cached != NULL) {
|
|
257
236
|
Py_INCREF(cached);
|
|
258
237
|
*out_pattern = (PatternObject *)cached;
|
|
259
|
-
pattern_cache_touch(state, cache_key);
|
|
260
238
|
} else if (PyErr_Occurred()) {
|
|
261
239
|
pattern_cache_release_state(lock_held);
|
|
262
240
|
return -1;
|
|
@@ -1806,11 +1806,6 @@ Pattern_compile_cached(PyObject *pattern_obj, uint32_t flags, int jit, int jit_e
|
|
|
1806
1806
|
return NULL;
|
|
1807
1807
|
}
|
|
1808
1808
|
|
|
1809
|
-
if (PyObject_Hash(cache_key) == -1) {
|
|
1810
|
-
PyErr_Clear();
|
|
1811
|
-
use_cache = 0;
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1814
1809
|
if (use_cache) {
|
|
1815
1810
|
PatternObject *cached = NULL;
|
|
1816
1811
|
if (pattern_cache_lookup(cache_key, &cached) == 0) {
|
|
@@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"
|
|
|
9
9
|
|
|
10
10
|
[project]
|
|
11
11
|
name = "PyPcre"
|
|
12
|
-
version = "0.2.
|
|
12
|
+
version = "0.2.12"
|
|
13
13
|
description = "Modern, GIL-friendly, Fast Python bindings for PCRE2 with auto caching and JIT of compiled patterns."
|
|
14
14
|
readme = "README.md"
|
|
15
15
|
requires-python = ">=3.9"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|