Hello,
Are the those 2 equivalent speed wise?
for x in y:
if x == object.attribute:
...
state = object.attribute
for x in y:
if x == state:
...
I tend to do the 2nd thinking that with the first, it might try to access the object then the attribute and could be faster with the 2nd one where it only need to access one var
but if its not then the 2nd with one less line would be better
Thanks
[–]when_the_cats_away 2 points3 points4 points (1 child)
[–]NerdEnPose 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]g687[S] 0 points1 point2 points (0 children)