This repository was archived by the owner on Dec 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dynamically compile spec'd __init__ functions
init_func_generator() previously used a single argument-less `init` base function coupled with a locals() hack to build spec-aware __init__() functions. This worked well, but profiling indicated that we were spending a good amount of time calling locals() and dict.copy()'ing its result. We now dynamically generate unique, per-spec __init__() functions using compile(..., 'exec'). This results in much faster runtime performance at the expense of a little compile-time complexity. The benchmark indicates this change results in ~10% faster decoding (for both the native and cybin implementations). Also, because this code no longer requires version-specific code paths, it can be moved out of _compat.py and into thrift.py.
- Loading branch information
Showing
2 changed files
with
32 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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