Skip to content

Commit

Permalink
Optimization: Compare class name directly
Browse files Browse the repository at this point in the history
Previously, using str() parsed and caused a large
overhead (this is 91% more efficient per my janky benchmark!)
  • Loading branch information
SinaKhalili committed Oct 9, 2024
1 parent 993e36a commit 8eb0c93
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/driftpy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
import zlib

from borsh_construct.enum import _rust_enum
from solders.pubkey import Pubkey
from sumtypes import constructor


def is_variant(enum, type: str) -> bool:
return type in str(enum)
return type == enum.__class__.__name__


def is_one_of_variant(enum, types):
Expand Down

0 comments on commit 8eb0c93

Please sign in to comment.