MadPhysicist
MadPhysicist

Reputation: 5831

Real-life module reloading in Python?

I am going through a book on Python which spends a decent time on module reloading, but does not explain well when it would be useful.

Hence, I am wondering, what are some real-life examples of when such technique becomes handy?

That is, I understand what reloading does. I am trying to understand how one would use it in real world.

Edit:

I am not suggesting that this technique is not useful. Instead, I am trying to learn more about its applications as it seems quite cool.

Also, I think people who marked this question as duplicate took no time to actually read the question and how it is different from the proposed duplicate. I am not asking HOW TO reload a module in Python. I already know how to do that. I am asking WHY one would want to reload a module in Python in real life. There is a huge difference in nature of these questions.

Upvotes: 4

Views: 110

Answers (2)

abukaj
abukaj

Reputation: 2712

As an appendix to DYZ's answer, I use module reloading when analysing large data in interactive Python interpreter.

Loading and preprocessing of the data takes some time and I prefer to keep them in the memory (in a module BTW) rather than restart the interpreter every time I change something in my modules.

Upvotes: 0

DYZ
DYZ

Reputation: 57033

Module reloading (also known as "hot-swapping") is commonly used in long-running systems, such as telephone switch software, that cannot be shut down for maintenance without causing costly service interruption. Such systems are upgraded piece-wise, one module at a time. For example, hot-swapping is natively supported at the implementation level by Erlang.

Python systems rarely run for long time. Real-life module reloading in Python does not seem to be of major importance.

EDIT: As @Aaron suggested, module reloading is used in some Python IDEs to facilitate module development.

Upvotes: 3

Related Questions