How Flask loads blueprint internaly?

Posted by Ignas B. on Stack Overflow See other posts from Stack Overflow or by Ignas B.
Published on 2012-08-28T18:57:40Z Indexed on 2012/11/12 11:02 UTC
Read the original article Hit count: 236

Filed under:
|
|

I'm just interested how Flask's blueprints gets imported. It still imports the python module at the end of all the stuff done by Flask and if I'm right python does two things when importing: registers the module name in the namespace and then initialize it if needed.

So if Flask blueprint is initialized when it gets registered, so all the module then is in memory and if there are lots of blueprints to register, the memory just gets wasted, because in one request basically you use one blueprint. Not a big loss but still...

But if it is only registered in the namespace and initialized only when needed (when the real request reaches it), then it make sense to register them all at once (as is the recommended way I understood). This is I guess the case here :) But just wanted to ask and understand a bit deeper.

© Stack Overflow or respective owner

Related posts about python

Related posts about flask