Because Fibonacci numbers are quite abused in programming, a similar concept. My first impulse is to describe them in recursive way: But this is not very efficient to calculate them, as for each is calculating all the previous ones, recursively. Here memoization works beautifully Taking into account that it uses more memory, and that calculating the Nth element without calculating the previous ones is also costly. I saw this on Programming Praxis, and I like a lot the solution proposed by Graham on the comments, using an iterator. The code is really clean.
Good news everyone! The new version of find (0.8) is available in GitHub and PyPi. This version includes performance improvements, man page and fuzzy search support. Enjoy!
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… Read More
I saw yesterday live the Apple keynote on the WWDC. I am far from an Apple developer, but I use OS X and iOS everyday, and I’m interested on new stuff. There was a full section devoted to developers, which is great (well, it’s supposed to be a developer’s conference, after all), and, arguably, the most interesting stuff on that part (for a developer’s perspective) was the release of a new programming language, Swift. It was announced with an (irrelevant) comparison with Python in terms of speed (I actually have plans to write… Read More