Code compatible with a GPL licensed program published under a different license (GNU gettext)
<h3>Context:</h3>
<p>The Python standard library already contains a <code>gettext</code> module roughly compatible with the original GNU gettext library. Simply this module does not use the hash tables present in mo files to speedup accesses without loading the whole thing in memory.</p>
<p>I wondered if it would be easy to implement that hash table lookup and eventually be able to generate the table and dived into GNU gettext library sources. I soon thought that there would be no technical difficulties.</p>
<p>Details:</p>
<p>The hashing algorithm is not documented outside the source code, and the only way to write a compatible code even from scratch is to find in the code:</p>
<ul>
<li>the details of the hash function (it is a derivative of P.J Weinberger hash function)</li>
<li>the lookup function which uses that hash function and a second function to deal with conflicts</li>
<li>the method for determining the size of the hash table</li>
</ul>
<p>The first 2 elements are in LGPL copyrighted source code, the last is in GPL copyrighted source code.</p>
<p>Everything else is documented and can be written from scratch with no need for copyrighted material.</p>
<h3>Problem:</h3>
<p>I would like to use the Apache Free License 2.1 for my own work, which is of course a free license but incompatible with both GPL and LGPL. The goal would be to able to later contribute it to the Python Standard Library which uses its own PSF license and require an Apache license from its contributors.</p>
<h3>Question:</h3>
<p>Most of the code would of course be written from scratch, and what I would borrow from GPL or LGPL licensed code would be a very little yet essential part. Would it be acceptable or would it be a copyright infringement? Specifically would it still be a <em>derivative work</em>? And could all this be a <em>fair use</em> of the copyrighted material?</p>

<p>Companies who try to avoid software copyright infringement use a "clean-room" method.  In one "room", people dig into the code of whatever is being copied and write up detailed specs.  In another "room", people take the detailed specs and write the code.  The resulting software is going to look like the original in many ways, and it would be difficult to prove a lack of infringement otherwise.  </p>

<p>In any case, if you're copying an essential part from the LGPL/GPL code, you're infringing copyright.  If you can't easily rewrite it, it's got to be sufficiently original and significant to be under copyright.  Your version would be a derivative work.</p>

<p>As far as fair use goes, the fact that you're trying to replace the existing work in its own field is likely to doom that.  Your use would not be transformative, and it's a deliberate attempt to cut into the market share of the original.</p>

licensing fair-use gpl