Implemented `de_activate` in mcpyrate.activate
This disables macros after loading the plug-ins. Now the timing is 160 ms, 30% faster than `mcpy` and 4 times faster than `macropy`
This commit is contained in:
parent
a62c3440e3
commit
52a29c26d7
|
|
@ -26,10 +26,23 @@ the `PYTHONDONTWRITEBYTECODE` environment variable, and the attribute
|
|||
'''
|
||||
|
||||
from importlib.machinery import SourceFileLoader, FileFinder
|
||||
|
||||
from .importer import source_to_xcode, path_xstats, invalidate_xcaches
|
||||
|
||||
SourceFileLoader.source_to_code = source_to_xcode
|
||||
# we could replace SourceFileLoader.set_data with a no-op to force-disable pyc caching.
|
||||
SourceFileLoader.path_stats = path_xstats
|
||||
FileFinder.invalidate_caches = invalidate_xcaches
|
||||
|
||||
def activate():
|
||||
SourceFileLoader.source_to_code = source_to_xcode
|
||||
# we could replace SourceFileLoader.set_data with a no-op to force-disable pyc caching.
|
||||
SourceFileLoader.path_stats = path_xstats
|
||||
FileFinder.invalidate_caches = invalidate_xcaches
|
||||
|
||||
|
||||
def de_activate():
|
||||
SourceFileLoader.source_to_code = old_source_to_code
|
||||
SourceFileLoader.path_stats = old_path_stats
|
||||
FileFinder.invalidate_caches = old_invalidate_caches
|
||||
|
||||
|
||||
old_source_to_code = SourceFileLoader.source_to_code
|
||||
old_path_stats = SourceFileLoader.path_stats
|
||||
old_invalidate_caches = FileFinder.invalidate_caches
|
||||
activate()
|
||||
|
|
|
|||
Loading…
Reference in New Issue