Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
caching attribute reference
#16
(Feb-22-2017, 09:14 AM)Skaperen Wrote: i'm trying to think of a way to test it that itself won't be optimized.  for example putting some code in a loop could end up with it recognize no change so 10000046 times around won't do so much.

The difficulty is finding something the compiler cannot optimize and that doesn't take time (because you are possibly looking for a handful of processor cycles).

Draw a random integer (to avoid a literal the compiler could optimize). Add it to some variable on each iteration, print the variable at the end (otherwise the compiler may thing it's useless). If you think the compiler could just do a multiplication, then use an array of two ints, and add the number to either member of the array depending on parity.
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
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