If I load a module in Python, will it ever be garbage collected? Another way of framing this question is, where does Python keep references to Python modules? As I assume if there are no longer any references, the garbage collector will remove a module.

Here's an example I tried in the in Python interpreter:

```
>>> from importlib import import_module
>>> import sys
>>> import gc

>>> x = import_module('math')
>>> 'math' in sys.modules

```

This outputs:

> 
> True
> 
> 
> 

So let's delete the reference to the module in the script.

```
>>> del x
>>> gc.collect()
>>> 'math' in sys.modules

```

Python still keeps track of the math module, as the output is still:

> 
> True
> 
> 
> 

But now if I delete math from `sys.modules`, I no longer am aware of any further references:

```
>>> del sys.modules['math']
>>> gc.collect()

```

Howver, the output of `gc.collect()` is:

> 
> 0
> 
> 
> 

Nothing was garbage collected, so the module is no longer in `sys.modules` or my script. Why was it not garbage collected?