Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
An optimization technique where function calls are cached to avoid duplicate computations.
4
votes
Accepted
Implementation of Longest Common Subsequence
You could use an explicit memoizer rather than incorporating caching into your function.
This will make your function easier to understand.
You can use functools lru_cache if you are using Python3.
Y …
2
votes
Determine all ways a string can be split into valid words, given a dictionary of all words
Honestly it looks like you're doing this wrong. Currently you're splitting the word into \$n^2\$ words and checking if they are in the dictionary. Rather than doing this you can traverse a Trie and lo …
8
votes
Accepted
Memoizing decorator that can retry
Naming
self.retry_times
You retry retry_times - 1 times, in all your loops.
Consider renaming this or removing the - 1's to make it more understandable.
forget
This remembers, always. It just doesn …
4
votes
Memoizing decorator with retries, part 2
Your code is broken:
__forget=False needs to be before **kwargs.
retry is undefined. (But is not used)
MappingProxyType is not hashable, and so you can't memoize it.
To fix the problem with Mappin …