Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use __iter__ rather than the inefficient nested for loops #873

Merged
merged 1 commit into from

2 participants

@legoktm

Since you can iterate over a cookiejar, this is simpler and more efficient than using nested for loops.

@kennethreitz
Owner

+1

@kennethreitz kennethreitz reopened this
@kennethreitz kennethreitz merged commit 1cb31f2 into kennethreitz:develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 5 deletions.
  1. +2 −5 requests/utils.py
View
7 requests/utils.py
@@ -311,11 +311,8 @@ def dict_from_cookiejar(cj):
cookie_dict = {}
- for _, cookies in list(cj._cookies.items()):
- for _, cookies in list(cookies.items()):
- for cookie in list(cookies.values()):
- # print cookie
- cookie_dict[cookie.name] = cookie.value
+ for cookie in cj:
+ cookie_dict[cookie.name] = cookie.value
return cookie_dict
Something went wrong with that request. Please try again.