Closed
Conversation
355b75a to
4c9ff1a
Compare
Adds explicit import caching for Python modules and functions:
API:
- py:import/1 - Import and cache a module
- py:import/2 - Import module and cache a specific function
- py:flush_imports/0 - Clear all import caches
- py:import_stats/0 - Get cache entry count
- py:import_list/0 - List cached imports as #{Module => [Funcs]}
Key behaviors:
- __main__ is never cached (returns error)
- Caching is per-process namespace (via PID affinity)
- All Python execution commands benefit from the cache
Tests:
- py_import_SUITE: 12 tests for basic import functionality
- py_import_owngil_SUITE: 9 tests for OWN_GIL mode (Python 3.12+)
- Multi-process and concurrent stress tests included
4c9ff1a to
84325aa
Compare
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.
Summary
py:new_env/1,2to create reusable Python environments with initialization codepy:set_env/1,py:get_env/0,1,py:list_envs/0,py:destroy_env/1py:eval/execandpy_event_loop_pool:eval/execto use named env when setExample usage:
{ok, _} = py:new_env(<<"import numpy as np">>, #{name => numpy_env}), ok = py:set_env(numpy_env), {ok, Result} = py:eval(<<"np.array([1,2,3])">>).