Hi guys. Recently my interview was published over at Mouse vs Python blog which is run by Mike. I am glad that I was able to become a part of Mike’s PyDev of the week series. This post is not going to be technical. I am going to use my time to clear up my mind through this post.
Originally posted on Wrong Side of Memphis:
This blog post by Dan Crosta is interesting. It talks about how is possible to optimise Python code for operations that get called multiple times avoiding the usage of Object Orientation and using Closures instead.
While the “closures” gets the highlight, the main idea is a little more general. Avoid repeating code that is not necessary for the operation.
The difference between the first proposed code, in OOP way
and the last one
The main differences are that both the config dictionary and the methods (which are also implemented as a dictionary) are not accessed. We create a direct reference to the value (categories and mode) instead of making the Python interpreter search on the self methods over and over.
This generates a significant increase in performance, as described on the post (around 20%).
But why stop there? There is another clear win in terms of access, assuming that the…
View original 310 more words
Hi there guys! If you have been following my recent posts then you might know that I have started a newsletter. This newsletter covers everything related to Python which I come across every week. Continue reading
Hi there guys! You might already be acquainted with tuples. A tuple is a lightweight object type which allows to store a sequence of immutable Python objects. They are just like lists but have a few key differences. The major one is that unlike lists, you can not change a value in a tuple. In order to access the value in a tuple you use integer indexes like: Continue reading
Hi there folks. I am writing a book on Python tips, tricks and patterns. This will be a short book of nearly 100 pages. I have already written about 56 pages. I would be self-publishing it in July or August. I am pretty sure that you would love this book. Here is an unsorted list of content which I have already written about: Continue reading
Hi there folks. It’s been a long time since I last published a post. I have been busy. However in this post I am going to share some really informative tips and tricks which you might not have known about. So without wasting any time lets get straight to them: Continue reading