-
Notifications
You must be signed in to change notification settings - Fork 48
Description
Mypyc currently uses heap allocated (boxed) CPython objects to represent float
values. This is both slow and can waste memory, especially once we support packed arrays (#840). Instead, represent float
values as C double values, similar to how we are going to support native integers (#837).
Native floats will use an overlapping error value, similar to native integers. We could potentially also reserve a specific NaN value to be used as an error value, but overlapping error values seem cleaner and they might even be more efficient, at least on some architectures.
We'll also need some primitives for math
functions such as math.sqrt
to avoid unnecessary boxing/unboxing and slow CPython calls. We don't need to cover all math
functions -- just the most common/fundamental ones are sufficient.
Open issues:
- How should we handle interactions with NumPy floating point types such as
numpy.float64
? - Which are the most important functions in
math
to support using primitives? - What to do with the
**
operator which can produceAny
types? The simplest thing is to just go with the types mypy can infer, and sometimes the result will be boxed.
The open issues don't need to be resolved to land an initial implementation.