1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Clarified cryptic comment in django/core/cache/backends/redis.py.

This commit is contained in:
Tim Graham
2025-03-05 20:02:23 -05:00
committed by GitHub
parent 8f942f1c1d
commit 9a729fb61a

View File

@@ -14,8 +14,9 @@ class RedisSerializer:
self.protocol = pickle.HIGHEST_PROTOCOL if protocol is None else protocol
def dumps(self, obj):
# Only skip pickling for integers, a int subclasses as bool should be
# pickled.
# For better incr() and decr() atomicity, don't pickle integers.
# Using type() rather than isinstance() matches only integers and not
# subclasses like bool.
if type(obj) is int:
return obj
return pickle.dumps(obj, self.protocol)