title: import inside a function: is memory reclaimed upon function exit?
body: <p>Linked questions:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/46813425/python-import-at-top-of-file-vs-inside-a-function">python - import at top of file vs inside a function</a></li>
  <li><a href="https://stackoverflow.com/questions/128478/should-python-import-statements-always-be-at-the-top-of-a-module?noredirect=1&amp;lq=1">Should Python import statements always be at the top of a module?</a></li>
  </ul>
  
  <p>If an <code>import</code> statement is inside a function, will the memory occupied by it get reclaimed once the function exits? If yes, is the timing of the reclamation deterministic (or even <strong>-ish</strong>)?</p>
  
  <pre><code>def func():
      import os
      ...
      # function about to exit; will memory occupied by `os` be freed?
  </code></pre>
  
  <p>If anyone has knowledge on the behavior of <a href="https://github.com/micropython/micropython" rel="nofollow noreferrer"><code>micropython</code></a> on this topic, bonus points.</p>