summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-09-03 10:51:04 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2018-09-03 12:32:20 +0200
commitef5358e8b8174716470b00691fba9946b7d307ce (patch)
tree08fdd290578728b624b5ba6e344f36a263d6873b /tests
parent66832138bfb0e82190b55fb410104d969cbc829b (diff)
Test symbolic constants with 'is (not)'
Saves a few % of total parsing time, and probably some evaluation time too. Microbenchmarking on Python 3 shows that 'is' is about 30% faster than '==' for comparing integers on my machine. This is safe even without assuming Python's small-integer optimization (which caches objects for small integers, guaranteeing that small integer literals always refer to the same object): We always refer to symbolic constants using their symbolic names (_T_*, etc.), so they're guaranteed to always refer to the same integer objects anyway. This optimization is safe for client code too, unless you get some unlikely situation where (1) there is no small-integer optimization, (2) expressions get pickled and unpickled or the like, which would be unsafe across Kconfiglib versions anyway, and (3) the client code tests symbolic constants with 'is' instead of '==' (which isn't advertised as safe, and a bad idea in general when pickling is involved). That's probably too obscure to worry about.
Diffstat (limited to 'tests')
0 files changed, 0 insertions, 0 deletions