(cls, source_code: str)
| 1823 | |
| 1824 | @classmethod |
| 1825 | def load(cls, source_code: str) -> CDLL: |
| 1826 | picked_vec_isa = pick_vec_isa() |
| 1827 | cpp_command = repr(cpp_compile_command("i", "o", vec_isa=picked_vec_isa)) |
| 1828 | key, input_path = write(source_code, "cpp", extra=cpp_command) |
| 1829 | if key not in cls.cache: |
| 1830 | from filelock import FileLock |
| 1831 | |
| 1832 | lock_dir = get_lock_dir() |
| 1833 | lock = FileLock(os.path.join(lock_dir, key + ".lock"), timeout=LOCK_TIMEOUT) |
| 1834 | with lock: |
| 1835 | output_path = input_path[:-3] + "so" |
| 1836 | if not os.path.exists(output_path): |
| 1837 | cmd = shlex.split( |
| 1838 | cpp_compile_command( |
| 1839 | input=input_path, output=output_path, vec_isa=picked_vec_isa |
| 1840 | ) |
| 1841 | ) |
| 1842 | compile_file(input_path, output_path, cmd) |
| 1843 | cls.cache[key] = cls._load_library(output_path) |
| 1844 | cls.cache[key].key = key # type: ignore[attr-defined] |
| 1845 | |
| 1846 | return cls.cache[key] |
| 1847 | |
| 1848 | |
| 1849 | class PyCodeCache: |
nothing calls this directly
no test coverage detected