On Fri, Aug 12, 2016 at 12:56 AM, Malcolm Greene <pyt...@bdurham.com> wrote: > Looking for some advice on how to optimize the BOILERPLATE portions of > the following type of code. There's an awful lot of dot dereferencing > going on. One thought was to pass in the values being dereferenced as > parameters and return value. But this would just move the dereferencing > to another point in my program and would add the overhead of parameter > passage. Is there a technique where I could store a reference to these > values that would make their access more efficient?
Until you find that the dereferencing of dots is actually hurting you, don't change anything. Most likely, it won't be a performance problem, so the only question is: Does this hurt code readability? And optimizing for code readability by adding levels of indirection is often a bad idea. What you MAY be able to do, though, if (as I'm guessing) the BOILERPLATE sections are repeated across lots of functions, is to refactor the functions to put those bits somewhere else. If nothing else, you could make a function decorator that surrounds the code with the appropriate boilerplate. But that's still indirection, and only worthwhile if there's a lot of duplication. Remember, every time you read this code, you'll need to go look elsewhere for the other half of the guts. ChrisA -- https://mail.python.org/mailman/listinfo/python-list