What is the fastest (to access) struct-like object in Python?

后端 未结 6 620
旧巷少年郎
旧巷少年郎 2020-12-07 11:08

I\'m optimizing some code whose main bottleneck is running through and accessing a very large list of struct-like objects. Currently I\'m using namedtuples, for readability

6条回答
  •  天命终不由人
    2020-12-07 11:23

    You can make your classes sequence like by adding __iter__, and __getitem__ methods, to make them sequence like (indexable and iterable.)

    Would an OrderedDict work? There are several implementations available, and it is included in the Python31 collections module.

提交回复
热议问题