Efficient integer floor function in C++

Casting to int is notoriously slow. Maybe you’ve been living under a rock since x86-64, or otherwise missed that this hasn’t been true for a while on x86. 🙂 SSE/SSE2 have an instruction to convert with truncation (instead of the default rounding mode). The ISA supports this operation efficiently precisely because conversion with C semantics … Read more

How do I find out what parts of my code are inefficient in Python

How do I see what inside the function is making the code take so long (Should I even use cProfile?) Yes, you can use cProfile but the way you asked the question makes me wonder if line_profiler (third party module, you need to install it) wouldn’t be a better tool. I’m using the IPython/Jupyter bindings … Read more

Why does concatenation of DataFrames get exponentially slower?

Never call DataFrame.append or pd.concat inside a for-loop. It leads to quadratic copying. pd.concat returns a new DataFrame. Space has to be allocated for the new DataFrame, and data from the old DataFrames have to be copied into the new DataFrame. Consider the amount of copying required by this line inside the for-loop (assuming each … Read more

What are the benefits to marking a field as `readonly` in C#?

I don’t believe there are any performance gains from using a readonly field. It’s simply a check to ensure that once the object is fully constructed, that field cannot be pointed to a new value. However “readonly” is very different from other types of read-only semantics because it’s enforced at runtime by the CLR. The … Read more

techhipbettruvabetnorabahisbahis forumuedusedusedusedueduseduedusedusedusedus