python - Why are you never supposed to reload modules? -


this question has answer here:

in "modules , packages: live , let die!", page 28 (see the video), it's said that:

you can force-reload module, you're never supposed it.

can explain why not supposed reload modules in python?

reloading explained in detail here: how unload (reload) python module?

tl;rd

there valid use cases reload, django development server. in general, reloading modules has many caveats practical.

two largest concerns are:

  1. to unload old objects, must make sure no other module or object keeps references them (which impossible). if fail here, may hard-to-trace memory leak or unexpected behavior.

  2. there no general way reload module c extensions. may reload safely; may seem reload safely, leak, , may crash interpreter or produce weird bugs.


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -