Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
caching attribute reference
#17
I came across on the web on such thin optimisations wich can impact a significant difference when it comes to iterating over hundreds of thousands or millions of objects.
So, basically Python search first the local scope for functions and other objects then the globals. And assignments like this make sense:

def squared(big_num):
    results = []
    append = list.append

    for n in big_num:
        results.append(n**2)

    return results
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
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