Friday, February 03, 2017

Big O

A post I left elsewhere tonight.  I'm playing around with the first bits of The Python Companion to Data Science. notes tell me a Python set should be approximately 15-30 times faster than a list, and Big O notation tells me I should see a more significant difference at the scale I'm using, but on lookup, it's about only twice as fast. I can't find anywhere that blames my copy of Windows for the problem, although I suspect it has something to do with that. no. PEBKAC. I was doing the list to set conversion inside my elapsed timer. Took it outside the elapsed timer code and I'm 60x faster on the actual lookup, which is the magnitude of difference I expected to see based on O(n) and O(1). I think I just invented my next question for an intern candidate. Go back to what you're doing. I'm O(1)k now.

The code in question...

No comments: