Because Mojo doesn’t support globally scoped variables, you must either import a Python module into each Mojo function that needs to use it
Is there a performance penalty for importing a Python module in a performance critical function?
Because Mojo doesn’t support globally scoped variables, you must either import a Python module into each Mojo function that needs to use it
Is there a performance penalty for importing a Python module in a performance critical function?
The short answer would be that there’s a performance cost to anything.
If you want to find out the costs in your particular case, you’d have to try it and measure it. For you the cost may be acceptable, and if it’s not you’ll have to import and module outside the hot path and eg. pass it in as a parameter.
Generally it doesn’t sound like the best approach to call Python in a hot path. You might also reconsider that structure and instead call Python only once processing is finished.