Skip to content

Instantly share code, notes, and snippets.


Saulius Žemaitaitis frgtn

View GitHub Profile
mgedmin /
Last active Sep 27, 2019
using timeit.timeit from pdb with access to a subset of local vars

= Problem =

timeit.timeit() doesn't let you pass local vars to the code to be timed.

= Solution =

(pdb) !import sys, timeit
(Pdb) !dv = (lambda sys=sys: (lambda **kw: setattr(sys.modules['__main__'], 'VARS', kw)))()
(Pdb) !tt = lambda s, sys=sys: sys.stdout.write('%.3g ms\n' % timeit.timeit(s, 'import sys; self = sys.modules["__main__"].SELF', number=10)/10.*1000)
dctrwatson / JenkinsDiffEventListener.php
Last active Jan 11, 2020
Jenkins Phabricator Inegration
View JenkinsDiffEventListener.php
* Copyright 2013 Disqus, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
You can’t perform that action at this time.