-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathdemo_pprint.py
35 lines (28 loc) · 1.03 KB
/
demo_pprint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
if __name__ == '__main__':
import time
import sys
import numpy as np
from stackprinter import format
def bump():
print('creating crazy data structures.')
boing = {k:np.ones((100,100)) for k in range(int(2e4))}
print('.')
somelist = [1,2,3,boing, boing, 4,5,6,7,8,9] * int(1e5)
print('done.')
somedict = {'various': 'excellent',
123: 'things',
'in': np.ones((42,23)),
'a list': somelist}
sometuple = (1,2, somedict, np.ones((32,64)), boing)
somedict['recursion'] = somedict
raise Exception('hello')
try:
bump()
except:
stuff = sys.exc_info()
scopidoped = 'gotcha'
tic = time.perf_counter()
msg = format(stuff, style='color', show_vals='all', reverse=False, truncate_vals=250, suppressed_paths=["site-packages"])
took = time.perf_counter() - tic
print(msg)
print('took %.1fms' % (took * 1000))