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

Remove typing cast that slowed the working of integer types #95

Merged
merged 3 commits into from
Jun 19, 2023
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
5 changes: 2 additions & 3 deletions malduck/ints.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABCMeta, abstractmethod
from struct import error, pack, unpack_from
from typing import Any, Callable, Generic, Iterator, Tuple, Type, TypeVar, Union, cast
from typing import Any, Generic, Iterator, Tuple, Type, TypeVar, Union

from .bits import rol

Expand Down Expand Up @@ -166,8 +166,7 @@ def __new__(cls: MetaIntType, value: Any) -> "IntType":
value = int(value) & cls.mask
if cls.signed:
value |= -(value & cls.invert_mask)
construct = cast(Callable[[MetaIntType, Any], IntType], int.__new__)
return construct(cls, value)
return int.__new__(cls, value) # type: ignore

def __add__(self, other: Any) -> "IntType":
res = super().__add__(other)
Expand Down