Repository navigation
Conversation
| if (type->types & MS_CONSTR_STR_REGEX) { | ||
| PyObject *regex = TypeNode_get_constr_str_regex(type); | ||
| PyObject *res = PyObject_CallMethod(regex, "search", "O", obj); | ||
| MsgspecState *st = msgspec_get_global_state(); |
Member
Contributor
Author
There was a problem hiding this comment.
Updated. The decoders now cache the module state and pass it to string validation. convert uses its existing module state
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cache the
searchmethod name in the module state and usePyObject_CallMethodOneArgfor string pattern validation.Extend the pattern tests to cover Unicode
\wmatches and$matching before a final newline.Warm JSON decode/validate/encode benchmarks against
main, with prebuilt decoders and encoders and no PCRE2 installed. Local Linux ARM64 Docker, CPython 3.14.7, pyperf 2.10.0, CPU 0 affinity, ABBA order, 30 measured values per variant and workload:An independent repeat with fresh builds gave 1.11x, 1.28x and 1.45x respectively, with no significant difference in the no-pattern control. The full-page result varied: one BA pair in the first run showed no significant difference. These are workload-specific local measurements, not an HTTP throughput estimate.
Benchmark workloads and commands
Save the script below as
benchmark.pyand download benchmark-data.zip into the same directory. The archive contains the same 100 city records used for the table; the script derives the same 299 identifiers from them. Decoder and encoder construction is outside the timed operation. The script reproduces the four workloads; measurements on newer source revisions may differ from the results above.The city fixture is adapted from GeoNames, under CC BY 4.0.
Use CPython 3.14.7 and two separate environments with the main and PR builds of msgspec installed, without PCRE2. In a new working directory containing
benchmark.pyandbenchmark-data.zip, set the environment paths below and run the ABBA sequence: