#4268·redis-py

Use ZRANGE REV for zrange(desc=True) on supported Redis versions

Author: sjquantCreated Aug 17, 2026Updated Aug 19, 2026

Version: redis-py 8.1.0, Redis 8.x Platform: Python 3.14 on macOS/Linux

Description:

The current redis-py README states that redis-py >= 6.0.0 supports Redis 7.2 to current.

Redis 7.2+ supports ZRANGE ... REV, while ZREVRANGE is deprecated:

However, the rank-only reverse path in Redis.zrange() still delegates to zrevrange():

python
redis.zrange("scores", 0, -1, desc=True)

This sends the following command on the wire:

ZREVRANGE scores 0 -1

For the currently supported Redis versions, the expected command would be:

ZRANGE scores 0 -1 REV

This appears to be a follow-up to the compatibility fix in #1697, which restored support for Redis versions older than 6.2. Those versions are no longer listed in the current supported-version matrix.

Expected behavior:

Could the legacy fallback be reconsidered for the currently supported Redis versions?

Possible approaches:

  1. Make zrange(desc=True) send ZRANGE ... REV by default.
  2. Add an explicit opt-in argument such as force_zrange=True or use_rev=True.
  3. Deprecate the legacy fallback and remove it in a future major release.

The current workaround is:

python
redis.execute_command("ZRANGE", "scores", 0, -1, "REV")

Would a backward-compatible opt-in API be preferred, or is removing the fallback acceptable given the current support matrix?