On 03/13/2017 01:18 AM, Markus Armbruster wrote: > Signed-off-by: Markus Armbruster > --- > scripts/qapi.py | 29 ++++++----------------------- > 1 file changed, 6 insertions(+), 23 deletions(-) > Reviewed-by: Eric Blake No idea if python actually behaves more efficiently, but this is a nice algorithmic change: > diff --git a/scripts/qapi.py b/scripts/qapi.py > index f06e3c4..5a3a606 100644 > --- a/scripts/qapi.py > +++ b/scripts/qapi.py > @@ -46,7 +46,7 @@ returns_whitelist = [] > # Whitelist of entities allowed to violate case conventions > name_case_whitelist = [] > > -enum_types = [] > +enum_types = {} > struct_types = [] > union_types = [] > all_names = {} > @@ -562,7 +562,7 @@ def find_alternate_member_qtype(qapi_type): > return builtin_types[qapi_type] > elif find_struct(qapi_type): > return 'QTYPE_QDICT' > - elif find_enum(qapi_type): > + elif qapi_type in enum_types: A good dictionary uses a tree structure for O(log n), or even hash lookup for amortized O(1) behavior here, > -def find_enum(name): > - global enum_types > - for enum in enum_types: > - if enum['enum'] == name: > - return enum > - return None > - while our lookup was O(n) on paper. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org