August 2nd, 2013, 05:17 PM
Showing Off the Clocker Script
So, remember all that time I spent working on something with timeit?
I think that might have paid off.
from pygos.clocker import Clocker
frame=list(placeholder) #'frame' and 'placeholder' start as copies of each other. This changes, however.
for item1 in placeholder:
for item2 in next_frame:
Using inspect, it figures out what everything is and from whence it is imported. Just throw it in "fetch" and it'll track down the source and make sure it's imported into the setup script.
Clocker.fetch-A list of functions, classes, or objects to track down from whatever modules they were in in the current session. On Clocker.make_script(), tracks them down and adds a relevant import statement to the setup script.
Clocker.setup-A list of variables to be defined in the setup script. Basically, for each key, creates a line "key=value". The value CAN be set to a normal value instead of a string containing it, but this only works in cases where __repr__ is a valid constructor (lists,dictionaries,and numbers, but not normal strings (they must be nested within additional '')). For best use, have your setup values all be strings.
Clocker.runcount- Pretty self-explanatory, just the number of times for timeit to run.
Clocker.make_script()-Exposed so that you can check and see that the script is there and working correctly. This is called automatically on Clocker.run().
Clocker.run()-Basically just times setup script and then gets results for all tests, runcount times, through timeit.
August 3rd, 2013, 10:16 PM
allforall forms the Cartesian product of its iterable of strings arguments. You've used it merely as a test program to demonstrate clocker. As a side note, allforall appears to work. I did
== 3*3*5, and also browsed the output, which looked correct. (allforall() raises an exception rather than returning . I do sometimes test edge cases. In other words, no arguments.)
clocker is a front end to timeit which I'll try harder to understand next time I want to time variant algorithms to express a problem solution. Who knows, I might remember this and provide feedback. I'll copy the thread URL into the program.
[/code] are essential for python code and Makefiles!
August 4th, 2013, 10:01 AM
Yes. For once, this wasn't asking for help. The forum is called "Python Programming", not "Python Help" or some such. :P
I thought this thread might provide a refreshing pause from the usual torrent of questions.
Yes, that is exactly what allforall does and was meant to do. I've wanted a program that does that for quite awhile. Couldn't think of anything clearer to name it. So I called it that as shortform for "all x for all y".
Thank you for taking the time to look at it and post, Dave.