Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Paste
P922
(An Untitled Masterwork)
Active
Public
Actions
Authored by
douardda
on Jan 15 2021, 11:44 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
In [8]: def t1(l):
...: for i in range(10000):
...: l = attr.evolve(l, instance_name=f"titi {i}")
...: return l
In [12]: %timeit t1(l, 10000)
105 ms ± 2.75 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [14]: def t2(l, n):
...: ld = attr.asdict(l)
...: for i in range(n):
...: ld["instance_name"] = f"titi {i}"
...:
...: return Lister(**ld)
In [15]: %timeit t2(l, 10000)
1.21 ms ± 35.2 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
Event Timeline
douardda
created this paste.
Jan 15 2021, 11:44 AM
2021-01-15 11:44:13 (UTC+1)
Log In to Comment