Skip to content
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

call __init__() in modules at init time #5960

Merged
merged 7 commits into from
Feb 27, 2014
Merged

call __init__() in modules at init time #5960

merged 7 commits into from
Feb 27, 2014

Conversation

JeffBezanson
Copy link
Member

The improvement here should be obvious. Less duplication, more locality, etc.

This will also make it very easy for packages to support precompilation.

This does the simplest thing that could work, leaving the following unsolved:

  • Order of initialization (though there is a stack, such that outer modules are initialized before inner)
  • Idempotence (though the system itself will not try to init a module more than once)

@StefanKarpinski
Copy link
Member

This rather sneakily sets a precedent about reserved names, implicitly make _name the de facto standard pattern. It might be better to do something like __init__.

@JeffBezanson
Copy link
Member Author

That name is fine with me.

JeffBezanson added a commit that referenced this pull request Feb 27, 2014
call __init__() in modules at init time
@JeffBezanson JeffBezanson merged commit 0049f4a into master Feb 27, 2014
@vtjnash
Copy link
Member

vtjnash commented Feb 28, 2014

why is this order best?

are you waiting to init inner modules until after the outer module is init, or before it is init, but after it is closed?

@JeffBezanson
Copy link
Member Author

I think officially, the order has to be undefined for now, since we have no way to guarantee it after deserialization. But I tried to pick an approach that would be less likely to cause problems.

Inner modules should be init after all their outer modules are closed, so they don't try to refer to something that might not have been defined yet. I also init outer modules first, but that's less important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants