Nasdaq / data-link-python

A Python library for Nasdaq Data Link's RESTful API
MIT License
428 stars 70 forks source link

session-per-request to session-over-time #16

Closed runawaycoast closed 2 years ago

runawaycoast commented 2 years ago

this PR changed from session-per-request to session-over-time.

previous implementation session-per-request: Every time we call API with get*, it will create a session within get_session() function.

Current implementation session-over-time:

  1. System creates a global variable session, initially be assigned with None.
  2. Once get_session() has been called for the first time, it will create the global session and setup retry strategy for it. (*)

con:

Screen Shot 2022-04-05 at 10 01 06 PM
  1 5 50 100 500 1000
non-reuse - function count 357108 398632 865777 1384827 5537227 10727727
reuse - function count 357119 396816 843351 1339501 5308701 10270201
             
  1 5 50 100 500 1000
non-reuse - second 0.55 0.69 1.42 2.43 8.71 16.768
reuse - second 0.53 0.61 0.9 1.38 4.67 8.68
runawaycoast commented 2 years ago

Close this pr in favour of #22