New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid circular import in registry #288
Comments
Interesting. I suspected that something was wrong when I was working on this global registry but I couldn't get my head around it. |
This is not an easy guess. Maybe mappings could be defined inside a JSON or in a config ATM this was my first idea, I am not saying its the best option. |
back on the saddle on this. I need some fresh ideas, let's see what can emerge, now. |
I think I've got something in this branch: https://github.com/peopledoc/workalendar/compare/288-new-registry Invoking @Natim because he was the one who implemented the ISO register in the first place. Do you remember why you've used OrderedDict? Does it really matter to remember the order of the items were inserted? |
You can probably get rid of it |
…ct's refs #375 and somehow refers to #288 ; when it has been raised here: #288 (comment)
…ct's refs #375 and somehow refers to #288 ; when it has been raised here: #288 (comment)
In current version (
3.0.0
) there is a circular import involvingregistry.py
which makes interpreter to fully load the whole library everytime a calendar is used.The circular may be summarized like this:
registry.py
-><continent-module>
-><country-cal>.py
->registry.py
. This however works thanks to how interpreters read the code (ie:iso_register
decorator is defined before importing every country inregistry.py
, so it works).To test this try:
You will see that to load a single calendar the whole library was loaded. This may be fine in some cases, but its a waste of execution time and memory.
A kind of lazy registry may perform better. However some kind of mapping and a bit of logic are required for this to be accomplished.
The text was updated successfully, but these errors were encountered: