Turşu nesnesi olarak depolanan 5 milyon dize öğesinin bir listesi var. Python listesi (set (a)) her seferinde siparişini değiştirir mi?
a = ['https://en.wikipedia.org/wiki/Data_structure','https://en.wikipedia.org/wiki/Data_mining','https://en.wikipedia.org/wiki/Statistical_learning_theory','https://en.wikipedia.org/wiki/Machine_learning','https://en.wikipedia.org/wiki/Computer_science','https://en.wikipedia.org/wiki/Information_theory','https://en.wikipedia.org/wiki/Statistics','https://en.wikipedia.org/wiki/Mathematics','https://en.wikipedia.org/wiki/Signal_processing','https://en.wikipedia.org/wiki/Sorting_algorithm','https://en.wikipedia.org/wiki/Data_structure','https://en.wikipedia.org/wiki/Quicksort','https://en.wikipedia.org/wiki/Merge_sort','https://en.wikipedia.org/wiki/Heapsort','https://en.wikipedia.org/wiki/Insertion_sort','https://en.wikipedia.org/wiki/Introsort','https://en.wikipedia.org/wiki/Selection_sort','https://en.wikipedia.org/wiki/Timsort','https://en.wikipedia.org/wiki/Cubesort','https://en.wikipedia.org/wiki/Shellsort']
sonra
list(set(a))
üzerinden tekrar bir liste yapılmış, ben
set(a)
kullanmak, yinelemeleri kaldırmak için.
Sorum şu:
Ben python yeniden başlatın ve turşu dosyasından listesini okumak bile, list(set(a))
sırası her zaman aynı olacaktır?
Bu karma -> liste düzeninin nasıl çalıştığını bilmek konusunda hevesliyim.
Küçük bir veri kümesiyle test ettim ve tutarlı bir sipariş var gibi görünüyor.
In [50]: a = ['x','y','z','k']
In [51]: a
['x', 'y', 'z', 'k']
In [52]: list(set(a))
['y', 'x', 'k', 'z']
In [53]: b=list(set(a))
In [54]: list(set(b))
['y', 'x', 'k', 'z']
In [55]: del b
In [56]: b=list(set(a))
In [57]: b
['y', 'x', 'k', 'z']
taşıma daha iki katı kadar bellek alır. –
Yeni başlayanlar için, karma siparişi garanti edilmez, dolayısıyla listenin sırası da garanti edilmez. – Makoto
[set-set] – MaxU