Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warmfix/change decoder cacheing #1842

Merged
merged 1 commit into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions bittensor/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,18 @@

T = TypeVar("T")


#######
# Monkey patch in caching the get_decoder_class method
# Monkey patch in caching the convert_type_string method
#######
if hasattr(RuntimeConfiguration, "get_decoder_class"):
original_get_decoder_class = RuntimeConfiguration.get_decoder_class
if hasattr(RuntimeConfiguration, "convert_type_string"):
original_convert_type_string = RuntimeConfiguration.convert_type_string

@functools.lru_cache(maxsize=None)
def cached_get_decoder_class(self, type_string):
return original_get_decoder_class(self, type_string)
def convert_type_string(cls, name):
return original_convert_type_string(cls, name)

RuntimeConfiguration.convert_type_string = convert_type_string

RuntimeConfiguration.get_decoder_class = cached_get_decoder_class

#######

Expand Down