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

后端 未结 6 625
旧巷少年郎
旧巷少年郎 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:24

    I would be tempted to either (a) invent some kind of workload specific caching, and offload the storage and retrieval of my data to a memcachedb-like process, to improve scalability rather than performance alone or (b) rewrite as a C extension, with native data storage. An ordered-dictionary type perhaps.

    You could start with this: http://www.xs4all.nl/~anthon/Python/ordereddict/

提交回复
热议问题