Skip to content

Fix import time regression by lazy-loading joining_types#211

Open
rodrigobnogueira wants to merge 2 commits intokjd:masterfrom
rodrigobnogueira:fix-import-time-regression
Open

Fix import time regression by lazy-loading joining_types#211
rodrigobnogueira wants to merge 2 commits intokjd:masterfrom
rodrigobnogueira:fix-import-time-regression

Conversation

@rodrigobnogueira
Copy link
Copy Markdown

@rodrigobnogueira rodrigobnogueira commented Feb 6, 2026

Addresses #188 following the @Dreamsorcerer idea. The joining_types dictionary (used for CONTEXTJ validation) is now wrapped in a @cache-decorated function to defer dictionary construction until first access.

  • Modified tools/idna-data generator to emit lazy-loaded format
  • Updated core.py to call joining_types() as a function
  • Regenerated idnadata.py with the new format

This reduces import time by ~40% (from ~6.5ms to ~3.7ms).

Addresses kjd#188. The joining_types dictionary (used for CONTEXTJ validation)
is now wrapped in a @lru_cache(None)-decorated function to defer dictionary
construction until first access. Uses lru_cache instead of cache for Python
3.8+ compatibility.

- Modified tools/idna-data generator to emit lazy-loaded format
- Updated core.py to call joining_types() as a function
- Manually regenerated idnadata.py (generator could not run due to network)

This reduces import time by ~53% (from ~6.5ms to ~3.1ms).
@rodrigobnogueira rodrigobnogueira force-pushed the fix-import-time-regression branch from 172177f to 67ac5ac Compare February 6, 2026 22:08
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