Author josh.r
Recipients josh.r, rhettinger, wdv4758h
Date 2016-01-12.01:37:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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)
Date User Action Args
2016-01-12 01:37:50josh.rsetrecipients: + josh.r, rhettinger, wdv4758h
2016-01-12 01:37:49josh.rsetmessageid: <>
2016-01-12 01:37:49josh.rlinkissue26082 messages
2016-01-12 01:37:48josh.rcreate