What is the most “pythonic” way to iterate over a list in chunks?
What is the most “pythonic” way to iterate over a list in chunks?
What is the most “pythonic” way to iterate over a list in chunks?
What is the most effective way for float and double comparison?
Performance optimization strategies of last resort [closed]
How do I profile a Python script?
I’ll do my best to explain it here on simple terms, but be warned that this topic takes my students a couple of months to finally grasp. You can find more information on the Chapter 2 of the Data Structures and Algorithms in Java book. There is no mechanical procedure that can be used to … Read more
Introduction For a technical overview – skip to this answer. For common cases where copy elision occurs – skip to this answer. Copy elision is an optimization implemented by most compilers to prevent extra (potentially expensive) copies in certain situations. It makes returning by value or pass-by-value feasible in practice (restrictions apply). It’s the only … Read more
Several tips: Put inserts/updates in a transaction. For older versions of SQLite – Consider a less paranoid journal mode (pragma journal_mode). There is NORMAL, and then there is OFF, which can significantly increase insert speed if you’re not too worried about the database possibly getting corrupted if the OS crashes. If your application crashes the … Read more
Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?
Your code is pretty fast (O(n)), but this problem can be solved in constant time (O(1)), since it is just based on the condition of the intersection of two lines being an integer. static String kangaroo(int k1, int v1, int k2, int v2) { float x = (k2 – k1)/(v1 – v2); if(x == (int) … Read more
Don’t bother about O(N). Simple algorithmic complexity is rarely a good answer regarding real-life performance. The expensive part isn’t iterating over the employee list, it’s sending an e-mail. If allowed by your requirements, you could use a single e-mail with multiple recipients, for example – of course, this will only work if all the e-mails … Read more