Skip to content

Is it possible to load a module/class once and not every time osxphotos query processes a photo #1696

Answered by RhetTbull
oPromessa asked this question in Q&A
Discussion options

You must be logged in to vote

This is something we might possibly be able to implement -- would need to think about it. Might be tricky to ensure things are injected into the right namespace, etc. However, here's a workaround that uses standard python behavior. In python, modules are only imported a single time. Any subsequent call to import uses the cached module. Thus, you could do this:

Create a new file named tf.py (or whatever you want) and in that file you do the slow class creation:

from timezonefinder import TimezoneFinder
import pytz
(...)
# Find the timezone based on latitude and longitude
tf = TimezoneFinder() # takes some time to load.
(...)

Then in your tzname.py, you import from this module:

from tf import 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@oPromessa
Comment options

Answer selected by oPromessa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants