Skip to content

Instantly share code, notes, and snippets.

View AvdN's full-sized avatar

Anthon van der Neut AvdN

  • Ruamel bvba
  • Braunschweig, Germany
View GitHub Profile
@andresriancho
andresriancho / ordered dict memory profiling.md
Last active August 29, 2015 14:21
Ordered dicts are hard (?)

TL;DR Use ruamel.ordereddict instead of Python's OrderedDict. Significant improvement in memory and CPU usage.

I was having memory issues with w3af so I started to experiment with different libraries for ordered dicts (since profiling was showing some strange things in that area). These are the results of some memory profiling tests I run:

  • Lower memory usage: 11.574 MiB ruamel.ordereddict
  • Higher memory usage: 69.742 MiB SQLMap's ordered dict; almost the same memory usage as the Python's collections.OrderedDict

When running the tests 100 times using timeit this is what I got on my workstation:

  • Faster: ruamel.ordereddict 7.66 seconds