Josh Rosenberg added the comment:

Given that lru_cache uses the cache dict in very specific ways, supporting 
arbitrary mapping types would be extremely hard. Among other things:

1. The C code uses the concrete dict APIs (including private APIs) that would 
not work on arbitrary mappings that don't directly inherit from dict (and often 
wouldn't work properly even if they do inherit from dict). Changing to use the 
abstract mapping APIs would slow all use cases for an extremely uncommon use 
case.

2. The C code is operating under the assumption that specific operations cannot 
release the GIL (e.g. dict insertion and deletion is done after precomputing 
the hash of the key, so it's impossible for Python byte code to be executed), 
so it can safely ignore thread safety issues. If a non-dict mapping was 
provided, implemented in Python rather than C, these assumptions could easily 
be violated.

3. This is basically a superset of the request from #23030, which rhettinger 
has rejected (you can read the rationale there)

----------
nosy: +josh.r, rhettinger

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26082>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to