Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
caching attribute reference
#1
in a class method, i need to access an instance attribute, such as self.foo and use that value many times.  is there any expected performance benefit to caching it in a local variable, such as doing foo = self.foo, and using just foo instead of self.foo for all the uses?  if i modify it i could do foo = whatever or foo += somenumber then finish with self.foo = foo.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
caching attribute reference - by Skaperen - Feb-21-2017, 06:24 AM
RE: caching attribute reference - by Larz60+ - Feb-21-2017, 10:42 AM
RE: caching attribute reference - by wavic - Feb-21-2017, 10:51 AM
RE: caching attribute reference - by ichabod801 - Feb-22-2017, 02:08 AM
RE: caching attribute reference - by Larz60+ - Feb-21-2017, 10:53 AM
RE: caching attribute reference - by wavic - Feb-21-2017, 11:02 AM
RE: caching attribute reference - by micseydel - Feb-21-2017, 05:30 PM
RE: caching attribute reference - by Larz60+ - Feb-21-2017, 05:37 PM
RE: caching attribute reference - by micseydel - Feb-21-2017, 06:00 PM
RE: caching attribute reference - by Larz60+ - Feb-21-2017, 08:00 PM
RE: caching attribute reference - by Skaperen - Feb-22-2017, 01:44 AM
RE: caching attribute reference - by Ofnuts - Feb-22-2017, 08:00 AM
RE: caching attribute reference - by micseydel - Feb-22-2017, 01:45 AM
RE: caching attribute reference - by Skaperen - Feb-22-2017, 02:16 AM
RE: caching attribute reference - by Skaperen - Feb-22-2017, 09:14 AM
RE: caching attribute reference - by Ofnuts - Feb-22-2017, 10:59 AM
RE: caching attribute reference - by wavic - Feb-22-2017, 11:20 AM
RE: caching attribute reference - by micseydel - Feb-23-2017, 03:43 AM
RE: caching attribute reference - by Ofnuts - Feb-23-2017, 08:12 AM
RE: caching attribute reference - by Skaperen - Feb-23-2017, 09:53 AM
RE: caching attribute reference - by micseydel - Feb-23-2017, 03:53 PM
RE: caching attribute reference - by Ofnuts - Feb-23-2017, 11:18 PM
RE: caching attribute reference - by wavic - Feb-23-2017, 04:20 PM
RE: caching attribute reference - by Skaperen - Feb-24-2017, 06:04 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pass by object reference when does it behave like pass by value or reference? mczarnek 2 2,593 Sep-07-2020, 08:02 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020