Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
size of set vs size of dict
#1
>>> n = 10000
>>> s = {x for x in range(n)}
>>> sys.getsizeof(s)
524512
>>> d = {x:1 for x in range(n)}
>>> sys.getsizeof(d)
295008

I would have expected size of set to be smaller than dict. But when I run such tests for different n I find frequently size of set is bigger. Why would be that be?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python code for alignment and font size 1418 0 273 Jan-14-2024, 03:56 AM
Last Post: 1418
Question [PyMuPDF] Grab all strings of a given size? Winfried 3 598 Dec-26-2023, 07:39 AM
Last Post: Pedroski55
  howto get size of a ctk image? janeik 2 780 Oct-03-2023, 03:49 AM
Last Post: janeik
  IndexError: index 10 is out of bounds for axis 0 with size 10 Mehboob 11 1,948 Sep-14-2023, 06:54 AM
Last Post: Mehboob
  How to do "fixed size" (wrapping) math in Python? AlexanderWulf 13 1,726 Jul-19-2023, 04:13 PM
Last Post: deanhystad
  Converted EXE file size is too large Rajasekaran 0 1,445 Mar-30-2023, 11:50 AM
Last Post: Rajasekaran
  help how to get size of pandas dataframe into MB\GB mg24 1 2,230 Jan-28-2023, 01:23 PM
Last Post: snippsat
  Tkinter Entry size limit vman44 3 6,393 Dec-22-2022, 06:58 AM
Last Post: vman44
  My pygame screen size Yegor123 2 1,218 Nov-06-2022, 12:36 AM
Last Post: Yegor123
  pygame screem size Yegor123 11 1,665 Oct-23-2022, 02:33 AM
Last Post: Yegor123

Forum Jump:

User Panel Messages

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