Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Set order
#2
As odd as this may sound, it is faster to compare sets BECAUSE they are unordered. Because sets are unordered, they can be optimized to access items by value (actually their hash value) instead of index. Kind of liked a lean dictionary without the value mapping. It is much faster to test that "u" is in set(alpha) than alpha.

You cannot use sets to compare collections when order is important. Obviously panagram != alpha, but they do have the same letters so set(alpha) == set(panagram).
Reply


Messages In This Thread
Set order - by FreshEire - Jan-09-2023, 05:06 PM
RE: Set order - by deanhystad - Jan-09-2023, 05:25 PM
RE: Set order - by woooee - Jan-09-2023, 06:08 PM
RE: Set order - by deanhystad - Jan-09-2023, 06:21 PM
RE: Set order - by woooee - Jan-09-2023, 06:35 PM
RE: Set order - by deanhystad - Jan-09-2023, 07:18 PM
RE: Set order - by bowlofred - Jan-09-2023, 07:20 PM
RE: Set order - by perfringo - Jan-09-2023, 07:26 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020