sarumont / py-trello

Python API wrapper around Trello's API
BSD 3-Clause "New" or "Revised" License
945 stars 330 forks source link

Use requests.Session in trello.trelloclient #303

Open delucks opened 4 years ago

delucks commented 4 years ago

Since the trello.TrelloClient object is typically long-lived and used for multiple calls to the Trello API, using requests.Session instead of requests.request() would allow us to take advantage of connection pooling for better efficiency and fewer round trips. This could potentially increase the performance of the entire library in one go. Default headers like Accept: application/json, API authentication with self.oauth, and proxy settings with self.proxies can be set at the Session level and reused between requests. Since the API for requests.Session is the same as the main requests API, this should be a nearly drop-in change.