Skip to content
Advertisement

Tag: list

python: class vs tuple huge memory overhead (?)

I’m storing a lot of complex data in tuples/lists, but would prefer to use small wrapper classes to make the data structures easier to understand, e.g. would be preferable over however there seems to be a horrible memory overhead: and Why? is there any obvious alternative solution that I didn’t think of? Thanks! (I know, in this example the ‘wrapper’

Checking if a list has duplicate lists

Given a list of lists, I want to make sure that there are no two lists that have the same values and order. For instance with my_list = [[1, 2, 4, 6, 10], [12, 33, 81, 95, 110], [1, 2, 4, 6, 10]] it is supposed to return me the existence of duplicate lists, i.e. [1, 2, 4, 6, 10].

How to find the smallest closest number in a list in python

I want to know how can I find the smallest closest number in a list to a given number. For example: I tried this: The output is 25 and not 15. The problem is that it always gives me the “biggest closest” and not the “smallest closest”. Answer You could make the key also contain the number itself and use

Advertisement