what's faster: merging lists or dicts in python? -


I am working with an app that is more bound to CPU-memory, and I want to merge two things Whether I am trying to get lists or fears, the thing is that I can choose one or the other, but I am thinking that the merging drafts will be faster because it is all in memory. is? Or is it always going to be O (n), n is the size of the small list.

Because of this, I asked about Dicket instead of set because I can not change Jason to a set, because the result is in {key1, key2, key3} and json has a key / value Pair is required, so I'm using a decree so that Jason Dump returns {key1: 1, key2: 1, key3: 1}. Yes, it is useless, but if it is proved fast, then I am fine with it.

EDIT: There is a difference in using the dict and the list to merge my question, I was originally and accidentally set and set

dict1 = {"the" : {"1": 1, "3": 1, "10": 1}

dict2 = {"the": {"11": 1, "13": 1}}

dict3 = {"the": {"1": 1, "3": 1, "10": 1, "11": 1, "13 If you are looking for duplicate elimination, the set is very fast.

  & gt; & Gt; & Gt; X = set (category (10000002000000)) & gt; & Gt; & Gt; Y = set (range (1900000, 29,000)) occurred in the following ~ 0.020s; Gt; & Gt; & Gt; Z = set.in window (X, Y)> and gt; & Gt; About Jason's production, just convert it to a list ... 

  json_encode (list) Div>  

Comments