-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
IntType is implementation of a concept to make a fixed-size int that behaves similarly to real int, so it's useful for reimplementation of code written in C language. It's natural that they're slower than native implementation, but current implementation is insanely slow because each operation creates new IntType object.
Each object initialization also comes with cutting value to the expected bitness.
Line 166 in 1f6ce66
| value = int(value) & cls.mask |
In the same time, base class of IntType is int which is immutable type.
Proposed solution is:
- implement wrapper based on https://docs.python.org/3/library/numbers.html#numbers.Integral instead of deriving from
int - make mutable IntType variant, so we avoid creating new objects in code that needs to work fast
- check if wrapping
ctypes.c_intworks faster than applying mask for each operation that could be overflowing.
Metadata
Metadata
Assignees
Labels
No labels