-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kw support in function_key_generator #43
Comments
Michael Bayer (zzzeek) wrote: i think i might have left this out after seeing how many bug reports there were in beaker regarding this. my hope was to leave it open ended so that it's not my problem. if you can figure out a way to add it to the API, e.g. in the docs "use key_gen = dogpile.foobar for this version", maybe that's OK. |
Andrey Petrov (shazow) wrote: So far I've been using this: https://gist.github.com/shazow/6838337 I'll mess around with it some more, but the code is almost identical to function_key_generator. Maybe once I get some better internet in a few days, I'll search for the aforementioned beaker bugs. Looks like kw and varargs are going to be fun edgecases. (Edited this comment about a million times. Sorries.) |
Michael Bayer (zzzeek) wrote: I do think that I want to do this. Not for for |
Andrey Petrov (shazow) wrote: Ugh just found this notification email in my 8th page of my Gmail spam label. What was I doing reading my 8th page of spam emails? Good question. Anyways, you want the PR as-is in the gist? Might be a while before I can get around to writing tests and such. (Feel free to just grab it from the gist, if it's easier.) |
Michael Bayer (zzzeek) wrote: not doing too much on DC right now, writing the tests is the hard part, ill let you know if i start doing them myself. |
Morgan Fainberg () wrote: @shazow I took a stab at this with https://bitbucket.org/zzzeek/dogpile.cache/pull-requests/46/add-a-key-word-arg-aware-cache-key/diff The key is that without the py3 semantic of using * and forcing arguments to be kwargs via the method/function def (or in py2, the positional package), there is a need to handle populating defaults and deconflicting the defaults when the arguments are passed positionally. I wasn't able to make it work in the short window I had with the multi_key_generator, but all of my tests (both synthetic in unit tests and direct use) seem to indicate this works. Ideally, this would make using the memoization decorators a little easier. The downside is that it [by very nature] has to mangle the cache keys since kwargs can happen in any order so this could break current cache-keys if someone was relying on them being stable even over DC upgrades. |
Andrey Petrov (shazow) wrote: @morgan_fainberg Excellent, thanks for taking over this! :) |
Michael Bayer (zzzeek) wrote: Add a key-word-arg aware cache-key generator Add in a key-word-arg cache key generator that may be optionally This was not made the default keygenerator to avoid reverse Fixes: #43 → 656df0b |
Changes by Michael Bayer (zzzeek):
|
Migrated issue, originally created by Andrey Petrov (shazow)
Any interest in adding kw support to function_key_generator using something like this? http://stackoverflow.com/questions/10920180/is-there-a-pythonic-way-to-support-keyword-arguments-for-a-memoize-decorator-in/10921408#10921408
Can send a PR if interested.
The text was updated successfully, but these errors were encountered: