There are a few responses here who seem not to have read the article or watched the video (note I didn't read the paper).
This is pretty amazing, and totally different from a memoizing decorator, and anything which could be done at the application level (unless it did deep deep magic; the kind you can't really do in Python).
Firstly, it is fully automatic. You don't need to annotate anything.
Secondly it works on impure functions! (as opposed to pure functions like fib.) It tracks data dependencies through the program, including global variables, external files(!), etc. If they do not change, then it uses a cached value.
Assuming that it works as he explains it in the video, this is properly amazing (and I've a PhD in compilers).
In comparison, a memoization decorator:
- requires you to annotate functions,
- can be accidentally put on functions which are not pure, which would lead to bugs and unsafe behaviour,
- does not (safely) support functions where data in the body of the function changes (such as global variables, external files, etc). Instead, it would only check the arguments.
I had the misfortune of reading the earlier comments and writing this off as a trivial accomplishment that could be disregarded, but now I know it is actually a useful tool to have in my arsenal.
hi everyone ... i'm the creator of IncPy and pleasantly surprised that it ended up on HN :)
anyways, this is still an early-stage research project where i'm the only developer, so i can't make much guarantees about its robustness (i can only test on my own machine with my own research scripts).
that said, though, i am very interested in getting new users and feedback. please email me at the email address listed on the IncPy website if you have any questions. i am more than happy to answer them!
I just tried to run Mercurial's test suite with it and it segfaults all over the place, unfortunately. It's too bad -- it seems like it could speed up some Mercurial operations quite a bit.
sorry that it didn't work out of the box; as you can tell, it's still a research prototype :)
i'll add the Mercurial test suite to my TODO list of programs to try. in your experience, what kind of Mercurial operations do you think can be sped up by memoization?
Erm, not really. Compiler cache saves compiled versions of files. When building a large project it notices things that have been built before and looks up the compiled code from a central cache. If you have to do a "make clean" (e.g. some scripts for making Debian packages start this way) you still get fast re-builds.
The linked article is about run-time memoization: rather than caching the compiled version of a function's code, you cache just the output of the function for particular inputs.
"rather than caching the compiled version of a function's code, you cache just the output of the function for particular inputs."
Think of the function as the compiler and the inputs as your C files. The kinds of things the two are doing are very similar, but incPy's job is much harder.
Yes you can cheat if you use your own memoizer too, if you "know" what your function does. Mine f'rinstance memoizes data fetched over the network even tho' as a function that is wildly impure, it can either age it out or check the last modification time. So I have one decorator for pure computations performed locally and impure performed remotely. Obviously this can only be done if the same person/team is maintaining both or it'll all go horribly wrong...
Not the same at all: IncPy stores the results to disc, so you can rerun your script and it will still have correct cache results for long running functions.
This is pretty amazing, and totally different from a memoizing decorator, and anything which could be done at the application level (unless it did deep deep magic; the kind you can't really do in Python).
Firstly, it is fully automatic. You don't need to annotate anything.
Secondly it works on impure functions! (as opposed to pure functions like fib.) It tracks data dependencies through the program, including global variables, external files(!), etc. If they do not change, then it uses a cached value.
Assuming that it works as he explains it in the video, this is properly amazing (and I've a PhD in compilers).
In comparison, a memoization decorator:
- requires you to annotate functions,
- can be accidentally put on functions which are not pure, which would lead to bugs and unsafe behaviour,
- does not (safely) support functions where data in the body of the function changes (such as global variables, external files, etc). Instead, it would only check the arguments.
Anyway, I'm impressed.