Skip to content

Commit

Permalink
feat[serializers]: specify empty __slots__ for serializer classes
Browse files Browse the repository at this point in the history
a little bit gain of memory usage for multiple instances
  • Loading branch information
spaceone committed Nov 6, 2021
1 parent cb07dbf commit 24ec9ab
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions shared_memory_dict/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def loads(self, data: bytes) -> dict:

class JSONSerializer:

__slots__ = ()

encoder = json.JSONEncoder
decoder = json.JSONDecoder

Expand All @@ -43,6 +45,9 @@ def loads(self, data: bytes) -> dict:


class PickleSerializer:

__slots__ = ()

def dumps(self, obj: dict) -> bytes:
try:
return pickle.dumps(obj, pickle.HIGHEST_PROTOCOL)
Expand Down

0 comments on commit 24ec9ab

Please sign in to comment.