There is a desire to specialize the remaining binary operations (including binary subscript).
However adding more and more specialized instructions is likely to make performance worse.
This idea is to have a lookup table of types pairs and function pointers. This is less efficient than inlining the code, but more extensible.
A single instruction can then support up to 256 specializations.
This will only work for immutable classes.
An ancillary mapping of (left, right) -> index will be needed for efficient specialization.
It is probably worth keeping the most common operations int + int, float + float, etc. inline.
We can replace BINARY_SUBSCR with BINARY_OP ([]) to allow effective specialization of BINARY_SUBSCR
E.g. subscripting array.array[int] can be handled with the registration mechanism described below.
markshannon commentedDec 14, 2022
There is a desire to specialize the remaining binary operations (including binary subscript).
However adding more and more specialized instructions is likely to make performance worse.
This idea is to have a lookup table of types pairs and function pointers. This is less efficient than inlining the code, but more extensible.
A single instruction can then support up to 256 specializations.
This will only work for immutable classes.
An ancillary mapping of
(left, right) -> index
will be needed for efficient specialization.It is probably worth keeping the most common operations
int + int
,float + float
, etc. inline.We can replace
BINARY_SUBSCR
withBINARY_OP ([])
to allow effective specialization ofBINARY_SUBSCR
E.g. subscripting
array.array[int]
can be handled with the registration mechanism described below.Registering binary functions at runtime
faster-cpython/ideas#162
The text was updated successfully, but these errors were encountered: