Python is NOT easy - lessons from SymPy's codebase
Sadhana Srinivasan (~rotuna) |
Python is generally considered an easy to use language and generally speaking, does not surprise the user and is known for being predictable. Even when one uses libraries in Python, one can generally predict how the library functions would behave or even be named with some experience.
This does not hold true when one actually tries to contribute to said libraries. A new contributor to open source projects often has to decode the codebase that has been written in Python but does not behave in ways that they have learned Python does.
This talk introduces a few such features (listed below), reasons about why these features are in-fact good, fantastic even. These are features that confounded me when I first started working with SymPy. The aim is to enable the new contributor to not be surprised by them and help them not come to a point where they would say, "Python is NOT easy".
Topics in the talk: - Intro (2 mins) - Inheritance in Python (5 mins)
Python allows multiple inheritance and has a kinda complex system for figuring out where a function's parent is.
Metaclasses (5 mins)
Classes that modify other classes without really telling you
Decorators (5 mins)
@i_will_change_your_class.before_its_attached_to_a_name - Mixin Classes (A Convention) (1 min)
Classes that allow different classes to behave the same in specific cases
Slots - Classes are not classes anymore (5 mins)
- How it all comes together (3 mins)
What will people learn from this talk? Who will this talk help? How can people use the knowledge they gain from this talk?
This is aimed at people who want to get involved with the Python open source community, especially with well established projects that have a large, sometimes "complex" codebases. It is meant to introduce some commonly used constructs in the open source community and largely derives from my experience with SymPy.
Anyone who wants to contribute to open source using Python as their base language would potentially benefit by seeing these constructs and knowing what they are, thereby making it easier for them to understand the codebase of the project they want to contribute to.
Target Audience: Intermediate users of Python who are looking to contribute to open source projects based in Python
Familiarity with Python
I am Sadhana Srinivasan.
I work at Saama Technologies as a AI Researcher, my primary interest is in Mathematics. Although I also studied Mechanical Engg while at BITS Pilani. I'm currenty working to try and impose Logical Rules on the outputs of ANNs.
I worked with SymPy to try an improve the speed of one their functions (expand) which I am using for one of my projects.