title: how to implement 'daisychaining' of pluggable function in python?
body: <p>here is the problem:</p>
  
  <p>1) suppose that I have some measure data (like 1Msample read from my electronics) and I need to process them by a processing chain.</p>
  
  <p>2) this processing chain consists of different operations, which can be swapped/omitted/have different parameters. A typical example would be to take this data, first pass them via a lookup table, then do exponential fit, then multiply by some calibration factors</p>
  
  <p>3) now, as I do not know what algorithm the the best, I'd like to evaluate at each stage best possible implementation (as an example, the LUTs can be produced by 5 ways and I want to see which one is the best)</p>
  
  <p>4) i'd like to daisychain those functions such, that I would construct a 'class' containing top-level algorithm and owning (i.e. pointing) to child class, containing lower-level algorithm.</p>
  
  <p>I was thinking to use double-linked-list and generate sequence like:</p>
  
  <p>myCaptureClass.addDataTreatment(pmCalibrationFactor(opt, pmExponentialFit (opt, pmLUT (opt))))</p>
  
  <p>where myCaptureClass is the class responsible for datataking and it should as well (after the data being taken) trigger the top-level data processing module (pm). This processing would first go deep into the bottom-child (lut), treat data there, then middle (expofit), then top (califactors) and return the data to the capture, which would return the data to the requestor.</p>
  
  <p>Now this has several issues:</p>
  
  <p>1) everywhere on the net is said that in python one should not use double-linked-lists
  2) this seems to me highly inefficient because the data vectors are huge, hence i would prefer solution using generator function, but i'm not sure how to provide the 'plugin-like' mechanism.</p>
  
  <p>could someone give me a hint how to solve this using 'plugin-style' and generator so I do not need to process vector of X megabytes of data and process them 'on-request' as is correct when using generator function?</p>
  
  <p>thanks a lot</p>
  
  <p>david</p>
  
  <p>An addendum to the problem:</p>
  
  <p>it seems that I did not express myself exactly. Hence: the data are generated by an external HW card plugged into VME crate. They are 'fetched' in a single block transfer to the python tuple, which is stored in myCaptureClass. </p>
  
  <p>The set of operation to be applied is in fact on a stream data, represented by this tuple. Even exponential fit is stream operation (it is a set of variable state filters applied on each sample).</p>
  
  <p>The parameter 'opt' i've mistakenly shown was to express, that each of those data processing classes has some configuration data which come with, and modify behaviour of the method used to operate on data.</p>
  
  <p>The goal is to introduce into myCaptureClass a daisychained class (rather than function), which - when user asks for data - us used to process 'raw' data into final form.</p>
  
  <p>In order to 'save' memory resources i thought it might be a good idea to use generator function to provide the data.</p>
  
  <p>from this perspective it seems that the closest match to what i want to do is shown in code of bukzor. I'd prefer to have a class implementation instead of function, but i guess this is just a cosmetic stuff of implementing <strong>call</strong> operator in particular class, which realizes the data operation....</p>