Write Python 3, while supporting Python 2.7

In this post I discuss an approach for writing code in Python 3, and still support Python 2.7. I've recently used this approach in one of my own projects. Most projects should get away with only minor modifications and an automatic translation step during package-build. However, there are some pitfalls (bytes/str) that might need special attention.

I've always been a proponent of Python 3, and I have been bashing Python 2 (a.k.a. legacy Python) at many opportunities. To be fair, Python 3 was announced just a few months after I started using Python, so I did not have much existing code that was holding me back. In fact I started writing Python 3 wherever the dependencies allowed it, and indeed the Pyzo IDE was written in Python 3 (almost) from the start. For most other projects, though, I have written code that runs on both Python 3 and Python 2.

There are comments.

more ...


The future of visualization in Python - are we going where we want to be?

Bokeh and VisPy are both awesome projects. However, I wonder whether we need to change where things are currently going. While Bokeh is great at 2D and the browser, 3D is not supported. While Vispy is super-fast and good at 3D and custom visualizations, it's support for the browser is poor. I don't want to tell scientists that they need two or three visualization libraries. I want it all in one library.

There are comments.

more ...

Performance gain for combining multiple GL objects into a single buffer

Rendering a set of 100.000 vertices with OpenGL is very fast. However, rendering 100 sets of 1000 vertices is significantly slower (even though the total number of vertices is the same). Therefore, in visualization libraries, collecting multiple objects in a single buffer can help increase performance. In this post I try to get a grip on how much this really matters. Result: it depends.

There are comments.

more ...

Comparing methods for box-layout in HTML

This post describes a small experiment that compares a few methods for doing a box-layout in HTML. On a variety of browsers the result was validated, and performance measured. The results show that the CSS display: flex method is the way to go.

There are comments.

more ...

Volume rendering in Vispy

We recently added volume rendering to Vispy. In this post I'll describe the method that is used, what the advantages of this method are, and possible future additions. I tried to be gentle and explain the method without giving too much boring details. Plus there is some fancy footage to demonstrate the new functionality.

There are comments.

more ...


Scientists need a dynamic programming language

Dynamic programming languages provide great advantages due to their interactive workflow, especially in science where algorithms are complex and take many iterations to get right. Developer time is more important than CPU time; writing all your code in a static language is (often) a bad case of premature optimization.

This post is a story about how I learned the importance of dynamic languages the hard way. I am sharing it here so that others might learn from it too. It also touches on some of the benefits of Python compared to Matlab.

There are comments.

more ...

The power of post-mortem debugging

Post-mortem debugging refers to the concept of entering debug mode after something has broken. There is no setting of breakpoints involved, so it's very quick and you can inspect the full stack trace, making it an effective way of tracing errors.

This post explains some of the benefits and how it can be used from IEP and other environments.

There are comments.

more ...