2 ms·
Sure, but for the purposes of a blog post that’s supposed to shine a light on performance considerations in specific, contrived examples, it would be a strawman
by mlthoughts2018 8y ago
Sure, but for the purposes of a blog post that’s supposed to shine a light on performance considerations in specific, contrived examples, it would be a strawman. Yet that’s the setting where you see a lot of people write e.g. a naive double loop algorithm in Python and criticize its performance compared with “the same” double loop algorithm in C.
It’s an uninformative comparison precisely because they are not “the same.” Pure Python looping (iterators) and doing pure Python operations in the loop body (run time type dynamics implicitly assumed to be needed/desired, heterogeneous container types of PyObject references assumed to be needed/desired) is conceptually a different thing than loops in C (simple increments) and, say, operations on a contiguous memory array, regardless of whether the syntax looks superficially similar to invite a visual comparison.