Details
-
Type:
Story
-
Status: Invalid
-
Resolution: Done
-
Fix Version/s: None
-
Component/s: afw
-
Labels:
Description
Looking up keys by string,
src['somefield']
|
is about 60x slower than pre-computing the key and using that,
key=src.schema.asKey()
|
src.get(key)
|
We should be able to cache those keywords in a dict to normalize that access speed and so that users don't have to deal with pre-defining and carrying around a bunch of keys.
I'll attach a simple ipython file that demonstrates the speed difference. The output of one run of it is shown below:
$ ipython field_key_timing.py
|
Small schema, string lookup
|
1 loops, best of 3: 214 ms per loop
|
Small schema, asKey() lookup
|
100 loops, best of 3: 3.35 ms per loop
|
|
Large schema, string lookup
|
1 loops, best of 3: 201 ms per loop
|
Large schema, asKey() lookup
|
100 loops, best of 3: 3.18 ms per loop
|
Run with ipython field_key_timing.py.