alt.Chart.from_dict
slow due to large number of calls to utils.schemaapi._use_referencing_library
#3382
Labels
alt.Chart.from_dict
slow due to large number of calls to utils.schemaapi._use_referencing_library
#3382
I'm the author of a FOSS library that makes extensive use of
alt.Chart.from_dict
.I noticed this is quite slow, and I think I have identified the root cause. Specifically,
alt.Chart.from_dict
makes a very large number of calls toutils.schemaapi._use_referencing_library
. In turn, this makes repeated calls toimportlib
, resulting in more than half of its runtime inimportlib.metadata
Since the result of
utils.schemaapi._use_referencing_library
is a bool and will not change within a Python session (it only changes if the user installs a different version of thejsonschema
package), it can be computed a single time, resulting in significantly improved performace.Reprex
Reprex including timings
The timings for the above on
main
are:on a 2019 macbook pro.
After removing the repeated
importlib
calls, the timings are:Solution
I've opened a PR that I think should address this
The text was updated successfully, but these errors were encountered: