Comparison of speed of np.sum in Cython

I was curious how much the overhead of np.sum impacted Cython code. That is, should you write your own sum method that loops or use np.sum? So, I wrote up a little test definition of the two approaches, as shown below:

Read More

Truncate to specified number of significant figures

It’s a simple request. You have a number, e.g. 1.25, and want to truncate it to say 2 significant figures. You specifically need to truncate instead of rounding, i.e. you need to get 1.2 instead of 1.3. How do you do that quickly in Python? Check out this code snippet:

Read More

Old posts

Old posts can be found at my old blog New things will be posted here from now on. I will likely revisit some of the older posts and create new versions here.

Read More