-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathex02.py
More file actions
35 lines (30 loc) · 760 Bytes
/
ex02.py
File metadata and controls
35 lines (30 loc) · 760 Bytes
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
from time import sleep, time
fake_users = [
{
"id": 1,
"name": "April Murphy",
"company": "Bailey Inc",
"email": "shawnlittle@example.org",
},
{
"id": 2,
"name": "Emily Alexander",
"company": "Martinez-Smith",
"email": "turnerandrew@example.org",
},
{
"id": 3,
"name": "Patrick Jones",
"company": "Young, Pruitt and Miller",
"email": "alancoleman@example.net",
},
]
def get_user_sync(uid: int) -> dict:
sleep(0.5)
(user,) = list(filter(lambda user: user["id"] == uid, fake_users))
return user
if __name__ == "__main__":
start = time()
for i in range(1, 4):
print(get_user_sync(i))
print(time() - start)