Merging two Python APIs without breaking compatability
<h2>Here is the scenario:</h2>

<p>Storage system <code>A</code> (Java) is the default and has a Python API <code>API_A</code>. Storage system <code>B</code> (Java/C++) was recently introduced, but did not have a Python API. People "somehow" made <code>B</code> work with <code>API_A</code>, but it is extremely slow, especially as the scale increases. Since, this was the only choice for a Python API, a lot of code now depends on <code>API_A</code> to interact with <code>B</code>.</p>

<p>The team from Storage system <code>B</code> now has a Python API, <code>API_B</code>. <code>API_B</code> is clearly more efficient. However, there are a lot of variations between <code>API_A</code> and <code>API_B</code>. For example, the list directory methods return objects with completely different fields. <code>API_B</code> does not allow recursive deletes for directories, but <code>API_A</code> does. And so on...</p>

<h2>The Question:</h2>

<p>What is the best way to merge the two APIs without breaking compatibility? In particular, since <code>API_A</code> has been in the use, what is the best way to integrate <code>API_B</code> into it transparently?</p>

<p>I don't think creating decorators will work as method signatures vary between the APIs. There are some methods in <code>API_A</code> not present in <code>API_B</code>. (Raising <code>NotImplementedException</code> is the only option here).</p>

<p>The only solution I can think of is the naive one, where I have to do this checking in every function in <code>API_A</code>:</p>

<pre><code>if self.isStorageA:
    return method_of_A(args)
else:
    return method_of_B(args, args)
</code></pre>

<p>I am looking for a better and more maintainable way to do this. Any help is greatly appreciated!</p>