1
0
mirror of https://github.com/django/django.git synced 2025-04-15 12:54:38 +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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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)