title: Most elegant way to configure a class in Python?
body: <p>I'm simulating a distributed system in which all nodes follow some protocol. This includes assessing some small variations in the protocol. A variation means alternative implementation of a single method. <em>All</em> nodes always follow the same variation, which is determined by experiment configuration (only one configuration is active at any given time). What is the clearest way to do it, without sacrificing performance?</p>
  
  <p>As an experiment can be quite extensive, I clearly don't want any conditionals. Before I've just used inheritance, like:</p>
  
  <pre><code>class Node(object):
  
      def dumb_method(self, argument):
          # ...    
  
      def slow_method(self, argument):
          # ...
  
      # A lot more methods
  
  class SmarterNode(Node):
  
      def dumb_method(self, argument):
          # A somewhat smarter variant ...
  
  class FasterNode(SmarterNode):
  
      def slow_method(self, argument):
          # A faster variant ...
  </code></pre>
  
  <p>But now I need to test <em>all possible variants</em> and don't want an exponential number of classes cluttering the source. I also want other people peeping at the code to understand it with minimal effort. What are your suggestions?</p>
  
  <p><strong>Edit</strong>: One thing I failed to emphasize enough: for all envisioned use cases, it seems that patching the class upon configuration is good. I mean: it can be made to work by simple <code>Node.dumb_method = smart_method</code>. But somehow it didn't <em>feel</em> right. Would this kind of solution cause major headache to a random smart reader?</p>