Skip to content

Instantly share code, notes, and snippets.

@tkmru
Created December 16, 2013 01:44
Show Gist options
  • Select an option

  • Save tkmru/7981202 to your computer and use it in GitHub Desktop.

Select an option

Save tkmru/7981202 to your computer and use it in GitHub Desktop.
Dict object consume some memory. Therefore if class don't have __dict__, memory consumed is restrained.You use "_slots_", you can do.
class Color(object):
__slots__ = ('r', 'g', 'b')
def __init__(self, r, g, b):
self.r = r
self.g = g
self.b = b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment