[Python] Iterators vs Generators

In Python, there are iterators and generators. You probably already use iterators without even knowing that you do so. But understanding the difference between those two concepts is really important since choosing one over the other has a huge impact on memory usage. If you are working with small datasets, memory usage might not be your first concern. However, with big datasets, it is another story. So what are they exactly, iterators and generators? Iterators The process of going through [...]

By | 2015-09-18T09:36:54+00:00 September 18, 2015|Categories: Bioinformatics, Performance, Python, Uncategorized|0 Comments

Mutable Default Arguments in Python

A member of the platform recently stumbled upon a bug in his python code. Once we got to the bottom of it, we were surprised to find that the bug in question had been caused by a peculiar behavior of Python. Let's take the following code as example : def foo(bar=[]):     bar.append('a') return bar Intuitively, this piece of code might seem like it ought to return the list ['a'] whenever it is run. In practice, it is not quite so. >>>foo() [...]

By | 2016-11-08T09:30:11+00:00 August 7, 2015|Categories: Python|0 Comments

Put Those CPUs to Good Use !

If you're like me, you've probably noticed that, by default, the python scripts we write only use a portion of the processing power at our disposal.. As such, you've probably said to yourself: Hey, I paid good money for a quad-core CPU ! What's happening ? While it's true that nowadays, most CPUs are multi-core, the code we write must also be tailored appropriately in order to make use of more than one at a time. So let's dive into [...]

By | 2017-04-12T11:53:19+00:00 July 12, 2015|Categories: Performance, Python|Tags: |0 Comments

Be better at programming with static program analysis

- What is static program analysis ? Static program analysis allows the gathering of informations about the execution behaviour of your code without actually executing it. It is the opposite of dynamic program analysis (like debugging) which required the code to be executed. - Ok! But why should I use this in practice ? To save time by suppressing the save/execute cycles induced by syntax errors (missing ";", function or variable not initialized, typos, ...). Correcting these errors at the [...]

By | 2016-11-08T09:30:14+00:00 May 8, 2015|Categories: Performance, Python, R, Web development|0 Comments

Database Content Versioning Using SQLAlchemy

One of the important functionality required of a LIMS is keeping a history of the changes applied to the data stored within the underlying database. This can be a tricky aspect to develop and/or put in place and there are certainly a number of ways one can go about implementing such a solution. Fortunately for all you SQLAlchemy fans out there, a fully implemented versioning solution is provided in the ORM's examples page. While the examples page provides a few [...]

By | 2016-11-08T09:30:17+00:00 October 5, 2014|Categories: LIMS, ORM, Python|Tags: |0 Comments