C++: Notes on moves and copies

I found the behavior of Objects in STL containers a bit confusing, so I wrote down some notes for myself. (I've updated this post after helpful comments from my colleagues Vladimir Semenyuk and Bj√∂rn Pollex. They pointed out that I hadn't implemented copy and move constructors in my original code. Hopefully the post now looks …

Advertisements

Derived classes and std::vector

I want to talk about a fun corner of C++ I ran into recently. It has to do with how to handle calling member functions of a list of heterogenous objects. My use case was a bit like the following: say we have a bunch of different functions - a * x^2, b * x, …

Why would I ever write in C?

I've made computers do tricks in both C/C++ and Python for many years now. For the past few years I've written exclusively in Python for both work and play. I recently went back to a personal project to rewrite it in C++ and, for the first time in my life, thought, "Why would I ever …

Get more out of Cython

Getting more out of your Cython code doesn't have to be a black art. A key step is to peek into the cythonized .c file and note if inner loops are getting down to bare C without any of the overheads associated with Python's dynamism. In an earlier post I had introduced Cython, which is …

CFFI-ize!

Ok, so it doesn't have as nice a ring to it as "Cythonize!" but the Python C-Foreign Function Interface blew my mind away. I had previously used Cython to write code that was a mind-altering mix of Python and C-like static type defs and so on. It was impressive how much speed you could gain …