improve generated code for import
This improves the generated code for loading vector export and scalar export.
Expected but missing fields (previously didn't exist or were @exportoff
d) no longer error immediately.
It is up to the constructor of the e.g. Particle type (or importconstruct
) to implement a sensible default.
In addition to that this change improves load time with 20k particles by x5-20 locally for me.
This should make some of the fix_import
functions obsolete.
This breaks the matching done in add_scalar_fallback
. This could now be done in importconstruct
or alternatively adapt the matching.
add_vector_fallback
will also no longer match. An importconstruct
would be easiest e.g.
InPartS.ExportUtils.importconstruct(t::Type{<:MotileCell}; ∫Fax=NaN, kwargs...) = t(; ∫Fax, kwargs...)
Compat with all cell models and fix_import will need to be ensured.
Merge request reports
Activity
requested review from @pbittih
Nice! I guess the speedup is simply from having the loop calling the constructor behind a function barrier?
I am wondering if it's somehow possible to reduce the complexity of the generated expressions (all the branching, etc), so it's easier to understand if we ever come back to this, and also easier to parse if we still need to.
- Resolved by Jonas Isensee
How do we deal with the warnings/safeguards? Besides particles and params, we also have more and more other types that are InPartS-exportable, and some of them might have simple numerical parameters with default values. If those get used accidentally, because some field is missing/renamed, it might slip through...
I implemented an alternative version over at !60 (closed) that is tested, in case we don't want to rely on narrowing down the types.
mentioned in commit df477093