Skip to content

Commit

Permalink
feat: optimize bound method instance cache (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Nov 26, 2024
1 parent 98aa2e3 commit 04f792b
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions a_sync/a_sync/method.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ class ASyncMethodDescriptor(ASyncDescriptor[I, P, T]):
return self
try:
bound = instance.__dict__[self.field_name]
# we will set a new one in the finally block
bound._cache_handle.cancel()
except KeyError:
from a_sync.a_sync.abstract import ASyncABC

Expand Down Expand Up @@ -318,8 +316,6 @@ class ASyncMethodDescriptorSyncDefault(ASyncMethodDescriptor[I, P, T]):
return self
try:
bound = instance.__dict__[self.field_name]
# we will set a new one in the finally block
bound._cache_handle.cancel()
except KeyError:
bound = ASyncBoundMethodSyncDefault(
instance, self.__wrapped__, self.__is_async_def__, **self.modifiers
Expand Down Expand Up @@ -405,8 +401,6 @@ class ASyncMethodDescriptorAsyncDefault(ASyncMethodDescriptor[I, P, T]):

try:
bound = instance.__dict__[self.field_name]
# we will set a new one in the finally block
bound._cache_handle.cancel()
except KeyError:
bound = ASyncBoundMethodAsyncDefault(
instance, self.__wrapped__, self.__is_async_def__, **self.modifiers
Expand Down Expand Up @@ -792,7 +786,7 @@ class ASyncBoundMethod(ASyncFunction[P, T], Generic[I, P, T]):
*iterables, concurrency=concurrency, task_name=task_name, **kwargs
).sum(pop=True, sync=False)
def __cancel_cache_handle(self, object instance) -> None:
def __cancel_cache_handle(self, instance: I) -> None:
"""
Cancel the cache handle.

Expand Down

0 comments on commit 04f792b

Please sign in to comment.