title: How bad is it to override a method from a third-party module?
body: <p>How bad is it to redefine a class method from another, third-party module, in Python?</p>
  
  <p>In fact, users can create NumPy matrices that contain <a href="http://pypi.python.org/pypi/uncertainties/" rel="nofollow noreferrer">numbers with uncertainty</a>; ideally, I would like their code to run unmodified (compared to when the code manipulates float matrices); in particular, it would be great if the inverse of matrix <code>m</code> could still be obtained with <code>m.I</code>, despite the fact that <code>m.I</code> has to be calculated with my own code (the original <code>I</code> method does not work, in general).</p>
  
  <p>How bad is it to redefine numpy.matrix.I?  For one thing, it does tamper with third-party code, which I don't like, as it may not be robust (what if other modules do the same?…).  Another problem is that the new numpy.matrix.I is a wrapper that involves a small overhead when the original numpy.matrix.I can actually be applied in order to obtain the inverse matrix.</p>
  
  <p>Is subclassing NumPy matrices and only changing their <code>I</code> method better?  this would force users to update their code and create matrices of numbers with uncertainty with  <code>m = matrix_with_uncert(…)</code> (instead of keeping using <code>numpy.matrix(…)</code>, as for a matrix of floats), but maybe this is an inconvenience that should be accepted for the sake of robustness?  Matrix inversions could still be performed with <code>m.I</code>, which is good…  On the other hand, it would be nice if users could build all their matrices (of floats or of numbers with uncertainties) with <code>numpy.matrix()</code> directly, without having to bother checking for data types.</p>
  
  <p>Any comment, or additional approach would be welcome!</p>