import_extension_from_bytes#

scikitplot.cython.import_extension_from_bytes(data, *, module_name, artifact_filename, temp_dir=None, key=None)[source]#

Import an extension module from raw artifact bytes.

Parameters:
databytes

Raw contents of a compiled extension artifact (.so / .pyd).

module_namestr

Module name the artifact was compiled for (init symbol name).

artifact_filenamestr

Filename to use when writing the artifact (must end with a valid extension suffix). This must be a simple filename (no directories).

temp_dirstr or os.PathLike or None, default=None

Directory to place the hash-scoped artifact file. If None, a platform temp directory is used.

keystr or None, default=None

Optional cache key to attach to the loaded module.

Returns:
types.ModuleType

Imported extension module.

Raises:
ValueError

If artifact_filename is invalid.

OSError

If a conflicting artifact already exists at the deterministic path.

ImportError

If the module cannot be loaded.

Parameters:
Return type:

ModuleType

Notes

Python extension modules cannot be imported directly from memory; the artifact must exist as a file on disk. This function writes the provided bytes to a deterministic location (by content hash) under temp_dir and imports it.