I have an application where I need to build a list or a dictionary and speed is important. Normally I would just declare a list of zeros of the appropriate length and assign values one at a time but I need to be able to check the length and have it still be meaningful.
Would it be faster to add a key value pair to a dictionary or to append a value to a list? The length of the lists and dictionary will usually be small (less than 100) but this isn't always true and in worst case could be much larger.
I could also just have a variable to keep track of where I am in the list if both of these operations are too slow.