You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have noticed pretty significant performance regressions when partially applying data types, like convert $ Float64, round $ Int, parse $ Int etc. To reproduce, take this as an example:
Notice the Tuple{DataType} in there. When compiling all the compiler sees is this signature: parse(::DataType, ::String), which is not enough information to compile type stable code.
The reason that happens is that
typeof(Int) # -> DataType
# same for all other data types
and that DataType is technically a concrete type but practically not really. Ideally this should be replaced with Type{Int}.
One way to fix this would be to supply a new specialized method for the $ function,
($)(f::Function, ::Type{T}) where T = ...
wherein the type parameter is manually set to Type{T}.
This problem has been solved before by the Fix1 type, see here.
Alternatively, I experimentally created my own partial application package. You can have a look how I solved the problem here.
I would offer the PR with a fix myself, but I have had very little time for hobby programming the past weeks, so I decided to just notify you about the problem instead 🤷♂️.
The text was updated successfully, but these errors were encountered:
Hello.
I have noticed pretty significant performance regressions when partially applying data types, like
convert $ Float64
,round $ Int
,parse $ Int
etc. To reproduce, take this as an example:The reason for this can be found when inspecting the type:
Notice the
Tuple{DataType}
in there. When compiling all the compiler sees is this signature:parse(::DataType, ::String)
, which is not enough information to compile type stable code.The reason that happens is that
and that
DataType
is technically a concrete type but practically not really. Ideally this should be replaced withType{Int}
.One way to fix this would be to supply a new specialized method for the
$
function,wherein the type parameter is manually set to
Type{T}
.This problem has been solved before by the
Fix1
type, see here.Alternatively, I experimentally created my own partial application package. You can have a look how I solved the problem here.
I would offer the PR with a fix myself, but I have had very little time for hobby programming the past weeks, so I decided to just notify you about the problem instead 🤷♂️.
The text was updated successfully, but these errors were encountered: