Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That code should only create the dict/namedtuple instance once, then access it many, many times.

The creation occurs in the --setup portion. The field accesses occur in the actual looping portion of the timeit code.



Ah, ok, I see, for some reason my browser wasn't showing the namedtuple code snippet right. Now I need to go look at the namedtuple code to see why accessing the fields by name is slower than accessing them by index.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: