Interestingly Stable Methods - prl-julia/julia-type-stability GitHub Wiki
For every package several most polymorphic methods -- in terms of number of return types across all observed calls. This number is given in parenthesis after a method name.
To go:
- Knet (v1.4.5)
- Plots (v1.10.6)
- Pluto (v0.12.21)
- Gadfly (v1.3.1)
JuMP (v0.21.6)
A greatly polymorphic package (also large): first five stable methods had 19+ return types.
-
MathOptInterface.get
(41+21): a container-operating extraction function, parametric in the type of contained elements. -
MathOptInterface.map_indices
(29): a form of identity function. -
build_constraint
(21+14): create a polymorphic wrapper. -
MutableArithmetics.add_mul
(19+14): generic arithmetic for library-defined types. -
_functionize
(16): the identity function. -
MutableArithmetics.sub_mul
(13): same asadd_mul
above. -
_add_or_set!
(13): a container-operating updating function, parametric in the type of contained elements. -
promote_operation
(13): type-level computation; in particular, the function returns the type of result of a given operation when applied to arguments of given types, and the method computes the output type of*
when applied to toT
(type parameter) (this is, unsurprisingly,T
).
IJulia (v1.23.2)
One method with 10 return types and all others have only one return types.
display_mimestring
(10): a form of identity function.
Genie (v1.16.0)
No methods with more that 2 return types.
-
secret_token!
(2): a form of identity function. -
gvector_to_jl
(2): a conversion/restructuring utility, parametric in the type of contained elements.
Gen (v0.4.2)
-
get_values_shallow
+get_submaps_shallow
(7+5): reshaping a container. Parametric. -
typecheck_arg
(6): the identity function (typechecking a "simple" value that has the same type in Julia as in their DSL). -
compile_dist_with_args
(5): turns one polymorphic struct into another with non-trivial amount of computations (!). -
get_submaps_shallow
(5): restructuring a data structure into a tuple (hence genericity). -
get_return_type
(5): type-level stuff (returns a type of a polymorphic input).
Flux (v0.11.6)
Consider two most-polymorphic methods, as others have 4 or less return types.
-
extraChain
(7 return types): it's amap ($ x)
over a tuple, so a parametric method. -
DataLoader
constructor (6 ret types): a parametric wrapper.
DifferentialEquations (v6.16.0)
-
dimension
(56 + 29 r.t.): extracts type info (dimension(u::Units{U,D}) where {U,D} = D
). -
unpack(_args)
(12+12): parametrically reshaping arguments. -
convert
from theStatic
package (9): convert term-holding type into the corresponding term (e.g. turnType{StaticInt{42}}
intoStaticInt{42}
). -
solution_new_retcode
(8+8): smart constructor. -
convert
: overloiading base functions to SIMDed datatypes. Parametric.
JSON.jl (v0.21.1)
Only 11.5% of stable methods (total 8) are interesting (supports conjecture 1) and the most polymorphic ones return only 3 different types. Going over those interesting stable methods in the order of decreasing number of return types:
-
lower
(src/Writer.jl:43
): is an identity function modulo wrapping the result into a polymorphic record. -
show_json
(src/Writer.jl:43
): a printing procedurs with some control-flow inside that makes it finish with different calls; 99% of time it returns eitherNothing
orUnion{}
which are morally equivalent. Once it returnsBool
which is weird.