Description
Elizaveta Shashkova - Monkey-patching: a magic trick or a powerful tool? [EuroPython 2016] [22 July 2016] [Bilbao, Euskadi, Spain] (https://ep2016.europython.eu//conference/talks/monkey-patching-a-magic-trick-or-a-powerful-tool)
Monkey-patching is a dynamic modification of a class or a module at runtime.
The Python gives developers a great opportunity to use monkey-patching almost everywhere. But should developers do it? Is it a magic trick or a powerful tool? In this talk we will try to give the answers to these questions and try to figure out pros and cons of using monkey- patching.
First of all we will learn what is monkey-patching in Python and consider some basic examples of using it.
Of course, monkey-patching may cause some problems in the code. We will consider bad ways to use it and try to learn different types of problems monkey-patching may lead to.
Despite of some bugs that may appear in a patched program, monkey- patching is used in a real life rather often. There are some reasons and motives to do it. We will consider the examples of using monkey- patching in real projects like gevent, in some other libraries and in testing. Also we will learn some monkey-patch tricks that helps to solve real-life problems in the Python debugger which is a part of the PyCharm and the PyDev.
After that we will compare using of monkey-patching in Python to using it in an another dynamic language Ruby. Are there any differences between them? Is our reasoning correct for Ruby?
Finally we will conclude all our thoughts and examples and try to give the answer to the question from title.