I need to save the set of list hashed by id : two lists are equal if they are the same object.
set
list
Not only does using tuple not make sense semantically , but I also need to mutate lists sometimes (add a few elements to the end every once in a while), so I can't use tuple .
tuple
How to save a hash set of lists hashed by id in Python?
Use dict instead of set, and let the id list be the key:
dict
id
dct[id(lst)] = lst
Check for a list in the "set" using id(lst) in dct .
id(lst) in dct
Source: https://habr.com/ru/post/1448029/More articles:How to position absolutely inside float: left? - htmlHow to manage a flexible flow - cssoptimization of log likelihood, transfer in different data sets - optimizationBackStack implementation for fragments in Android tabs - androidJava Random Class is not really random? - javaWhy AJAX json script returns extra 0 (zero) - jsonSetting headers on HttpServletResponse after writing response body - javaBuild error SpecsFor.Mvc - visual-studio-2012Rails manually redirects from bare domain - ruby-on-railsThe interview task on how to develop a program that will work with big data - javaAll Articles