Skip to content

Auto research json#143

Closed
Abhijeet Prasad (AbhiPrasad) wants to merge 32 commits intomainfrom
auto-research-json
Closed

Auto research json#143
Abhijeet Prasad (AbhiPrasad) wants to merge 32 commits intomainfrom
auto-research-json

Conversation

@AbhiPrasad
Copy link
Copy Markdown
Member

No description provided.

… existing benchmark suite aggregate across all 11 cases.

Result: {"status":"keep","bt_json_total_us":6806.403259418478}
…so deep-copy traversal avoids logger imports and pydantic/dataclass probing for the overwhelmingly common leaf values.

Result: {"status":"keep","bt_json_total_us":1459.11131989952}
… mappings with .items() so recursive traversal avoids calling _to_bt_safe for common leaf values and avoids extra dict lookups.

Result: {"status":"keep","bt_json_total_us":1052.0784615771965}
…paths; typing.Mapping incurs expensive runtime __instancecheck__ logic during every recursive container visit.

Result: {"status":"keep","bt_json_total_us":808.4420663400282}
…ast paths and add a string-key fast path, avoiding expensive ABC checks and unnecessary str() calls on the common recursive cases.

Result: {"status":"keep","bt_json_total_us":597.1877789749944}
…r cases in _to_bt_safe and bt_safe_deep_copy, falling back to isinstance only for subclasses and uncommon container implementations.

Result: {"status":"keep","bt_json_total_us":583.086666156607}
…ven pydantic probing with direct attribute checks (__dataclass_fields__, model_dump, dict), cutting overhead for dataclass objects and especially pydantic-v1-like models.

Result: {"status":"keep","bt_json_total_us":576.2479212949469}
…efore subclass scalar fallbacks, so common dict/list/tuple/set recursion avoids extra isinstance probes on every container node.

Result: {"status":"keep","bt_json_total_us":489.8326024747584}
…_bt_safe avoids repeating the in-function import path for non-primitive values while preserving the circular-import-safe initialization behavior.

Result: {"status":"keep","bt_json_total_us":482.174736600974}
… bt_safe_deep_copy so the hot container traversal avoids repeated integer addition on every element/key visit.

Result: {"status":"keep","bt_json_total_us":464.24171432099206}
…stance in _to_bt_safe, avoiding bound-method creation and redundant instance attribute lookups on dataclass/model inputs.

Result: {"status":"keep","bt_json_total_us":458.9441213200044}
…n all-built-in-string-key path avoids isinstance overhead while still coercing string subclasses and non-string keys safely.

Result: {"status":"keep","bt_json_total_us":445.26971205827834}
…ydantic v2 models (detected via __pydantic_serializer__), so model_dump-compatible non-Pydantic objects avoid the catch_warnings/filterwarnings overhead.

Result: {"status":"keep","bt_json_total_us":443.3354319026354}
…r-only dicts now finish without recursive calls, and mixed dicts recurse only once they hit the first non-scalar value while preserving key coercion and depth handling.

Result: {"status":"keep","bt_json_total_us":432.30320549698376}
…son payload mix so str/int hits happen before the rarely-taken None case in _to_bt_safe, bt_safe_deep_copy, and the new dict scalar-prefix fast path.

Result: {"status":"keep","bt_json_total_us":430.73053226363567}
…ng keys: the common all-string-key case now writes keys directly and only falls back to stringification once a non-string key is actually encountered.

Result: {"status":"keep","bt_json_total_us":416.8542630214215}
…ually needs recursion, so scalar-only dicts skip add/discard churn entirely while mixed dicts still detect cycles before descending.

Result: {"status":"keep","bt_json_total_us":409.41510602223036}
…y on their __dict__ when it exactly matches the dataclass field set, letting the heavily optimized dict fast path sanitize fields while preserving the existing fallback for slotted or dynamically-extended dataclasses.

Result: {"status":"keep","bt_json_total_us":400.99191405921846}
…t_safe_deep_copy, and the exact-dict scalar-prefix loop, only falling back to NaN/+/-Infinity handling for the uncommon non-finite cases.

Result: {"status":"keep","bt_json_total_us":395.8065035184231}
…l-object isinstance chain while keeping model_json_schema safely type-gated, so dataclasses and model-like objects avoid the cached special-type tuple fetch plus six unused isinstance checks.

Result: {"status":"keep","bt_json_total_us":393.92183346204956}
…he common list-of-dicts workload avoids an extra _deep_copy_object dispatch per element while preserving circular detection, key coercion, and depth handling.

Result: {"status":"keep","bt_json_total_us":370.0572772262796}
…ld that actually needs recursive descent, including the new list-of-dicts fast path, so scalar-prefix dicts skip upfront id/in-set work while still catching cycles before recursing.

Result: {"status":"keep","bt_json_total_us":366.36490207095034}
… path and send the rare non-dict elements to the fallback branch, matching the benchmark's overwhelmingly list-of-dicts container mix.

Result: {"status":"keep","bt_json_total_us":364.93806625247976}
…float branches in bt_safe_deep_copy so the recursively dominant dict/list/tuple/set nodes hit their hot path sooner, while still preserving the existing scalar fast paths and fallback semantics.

Result: {"status":"keep","bt_json_total_us":352.578193876466}
…allback checks in _to_bt_safe, so dataclass and model-like objects avoid failed isinstance(str/bool/int/float) probes while exact scalar fast paths and special-object handling stay intact.

Result: {"status":"keep","bt_json_total_us":350.61670127282156}
…_copy branches where membership is guaranteed, trimming a bit of defensive overhead from the hot exact-container and fallback container teardown paths.

Result: {"status":"keep","bt_json_total_us":350.21564039386595}
…aclass/model probing so common string subclasses (like enum-style span attributes) bypass the richer object-detection work without affecting exact scalar or model/dataclass handling.

Result: {"status":"keep","bt_json_total_us":349.94741905749265}
…nside the exact-list fast path so scalar/string list items avoid a full _deep_copy_object redispatch while the dominant list-of-dicts path stays unchanged.

Result: {"status":"keep","bt_json_total_us":344.83290970465237}
…dict/scalar/float branches, avoiding a redundant type() call on every non-dict list item while preserving the optimized list-of-dicts fast path.

Result: {"status":"keep","bt_json_total_us":348.1037284222322}
… path: scalar-only prefixes now return without paying a try/finally cleanup frame, and visited removal is only wrapped around the branch that actually recurses after the first non-scalar child.

Result: {"status":"keep","bt_json_total_us":335.9028560562187}
…dding the list itself to the visited set until the first child that actually needs recursive descent, so scalar-only and scalar-prefix lists skip unconditional add/remove overhead.

Result: {"status":"keep","bt_json_total_us":338.7206501108379}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant