Skip to content

Introduce an experimental rewrite using requests module

Leo P. Singer requested to merge leo-singer/gracedb-client:requests into master

(Note: please merge !9 (merged) first.)

This is an experimental, partial rewrite of the REST client that uses the Python requests module, which brings performance gains due to connection pooling and generally cleaner implementation. The speedup is impressive:

In [2]: old, new = rest.GraceDb(), requests.GraceDb()

In [3]: %timeit old.event('G211117')
1 loop, best of 3: 391 ms per loop

In [4]: %timeit new.event('G211117')
1 loop, best of 3: 88.5 ms per loop

In [5]: %timeit old.writeLog('T271297', 'foobar')
1 loop, best of 3: 688 ms per loop

In [6]: %timeit new.writeLog('T271297', 'foobar')
1 loop, best of 3: 286 ms per loop

In [7]: %timeit old.writeLog('T271297', 'foobar',
   ...: filename='bayestar.fits.gz')
1 loop, best of 3: 5.22 s per loop

In [8]: %timeit new.writeLog('T271297', 'foobar',
   ...: filename='bayestar.fits.gz')
1 loop, best of 3: 1.31 s per loop

Merge request reports

Loading