Python notes

Posted: Sunday, 2017-01-22 11:02 | Tags: Programming, Python

I've been watching some PyCon talks online lately and stumbled across a few interesting things, these are mostly notes for myself but feel free to consider them useful ;-)

  • A nice person wanted to get into programming and of course was easily convinced to not start with C++17 but rather Python. PyGame seemed a good choice to produce some quick results, however (at least on recent Ubuntu) is only available for Python2. PySDL is not such a great alternative either, as the interface seems slightly more technical. A more LÖVE-like alternative seems to be provided by Arcade.
  • Python 3.6 features a nice, more compact dict implementation, all the details are presented in the talk Modern Dictionaries by Raymond Hettinger. Also it was not until now that I found out pathlib exists, mostly because until recently it did not play well with os.path and thelike.
  • Another very nice talk by the same guy goes into how to actually write beautiful python code, I enjoyed this one very much: Transforming Code into Beautiful, Idiomatic Python.
  • Another talk (by Brett Slatkin) called How to be more effective with functions (in the last third), finally helped me understand how you build an iterator that is rewindable (last third of the video; very useful for large data-crunching tasks that need to iterate multiple times).
  • That guy also wrote a book about this and other topics called Effective Python: 59 Specific Ways to Write Better Python which I yet have to read.
  • The other book in my shopping cart is named High Performance Python: Practical Performant Programming for Humans and discusses when and how to use Numpy, Numba, Cython, etc.. to speed stuff up, but also goes a little into probabilistic algorithms (eg. Bloom Filters), for when memory/time is tight enough that you are willing to sacrifice accuracy for it.
  • Hypothesis is a nice extension to python unit testing that basically generates all the test data for you, caring about corner cases etc.. I have yet to try it out myself but I imagine it to have a potential to drastically reduce time spent developing test cases.