As a way to get used to python, I am trying to translate some of my code to python from Autohotkey_L.
I am immediately running into tons of choices for collection objects.
Can you help me figure out a built in type or a 3rd party contributed type that has as much as possible, the functionality of the AutoHotkey_L object type and its methods.
AutoHotkey_L Objects have features of a python dict, list, and a class instance.
I understand that there are tradeoffs for space and speed, but I am just interested in functionality rather than optimization issues.
Don’t write Python as
<another-language>. Write Python as Python.The data structure should be chosen just to have the minimal ability you need to use.
list— an ordered sequence of elements, with 1 flexible end.collections.deque— an ordered sequence of elements, with 2 flexible ends (e.g. a queue).set/frozenset— an unordered sequence of unique elements.collections.Counter— an unordered sequence of non-unique elements.dict— an unordered key-value relationship.collections.OrderedDict— an ordered key-value relationship.bytes/bytearray— a list of bytes.array.array— a homogeneous list of primitive types.Looking at the interface of Object,
dictwould be the most suitable for finding a value by keycollections.OrderedDictwould be the most suitable for the push/pop stuff.when you need MinIndex / MaxIndex, where a sorted key-value relationship (e.g. red black tree) is required. There’s no such type in the standard library, but there are 3rd party implementations.