When should I (not) want to use pandas apply() in my code?

apply, the Convenience Function you Never Needed We start by addressing the questions in the OP, one by one. “If apply is so bad, then why is it in the API?” DataFrame.apply and Series.apply are convenience functions defined on DataFrame and Series object respectively. apply accepts any user defined function that applies a transformation/aggregation on … Read more

Why does appending “” to a String save memory?

Doing the following: data.substring(x, y) + “” creates a new (smaller) String object, and throws away the reference to the String created by substring(), thus enabling garbage collection of this. The important thing to realise is that substring() gives a window onto an existing String – or rather, the character array underlying the original String. … Read more

Java Reflection Performance

Yes – absolutely. Looking up a class via reflection is, by magnitude, more expensive. Quoting Java’s documentation on reflection: Because reflection involves types that are dynamically resolved, certain Java virtual machine optimizations can not be performed. Consequently, reflective operations have slower performance than their non-reflective counterparts, and should be avoided in sections of code which … Read more

Controlling fps with requestAnimationFrame?

How to throttle requestAnimationFrame to a specific frame rate Demo throttling at 5 FPS: http://jsfiddle.net/m1erickson/CtsY3/ This method works by testing the elapsed time since executing the last frame loop. Your drawing code executes only when your specified FPS interval has elapsed. The first part of the code sets some variables used to calculate elapsed time. … Read more