Logo
Explore Help
Register Sign In
fengqi/lv_micropython
1
0
Fork 0
You've already forked lv_micropython
Code Issues Pull Requests 1 Actions Packages Projects Releases Wiki Activity
lv_micropython/tests/bench/var-8-namedtuple-1st.py

13 lines
190 B
Python
Raw Normal View History

tests/bench: Time namedtuple field access. That's higher than instance field access - behold the power of hashing.
2014-05-07 18:14:48 +03:00
import bench
from _collections import namedtuple
py: Use sequence of strings for named tuple initialization - remove single string initialization style - take list of strings instead - store list in the type for fast lookup
2014-12-20 16:37:40 +01:00
T = namedtuple("Tup", ["num", "bar"])
tests/bench: Time namedtuple field access. That's higher than instance field access - behold the power of hashing.
2014-05-07 18:14:48 +03:00
def test(num):
t = T(20000000, 0)
i = 0
while i < t.num:
i += 1
bench.run(test)
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.8 Page: 80ms Template: 1ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API