List of lists against the dictionary

In Python, are there any advantages / disadvantages of working with a list of lists and working with a dictionary, or rather, when performing numerical operations with them? I am writing a class of functions to solve simple matrix operations for my linear algebra class. I used dictionaries, but then I saw that I was numpyusing a list of lists, so I assume that it should have some advantages.

Example: [[1,2,3],[4,5,6],[7,8,9]]Unlike{0:[1,2,3],1:[4,5,6],2:[7,8,9]}

+5
source share
2 answers

I think it depends a lot on how you plan to use this structure.

Python ( ) . , , :

for list in dict.keys():
    for elem in list:
        # Logic

1, 2, 3..., , . - .

( , ), List. O (1), . , - ( , ).

, - , . . Stick .


, - . Ruby Python , (, , ). , .

+10

0, 1,..., n, list , . , dict.

+9

All Articles