The Python standard library already contains a gettext 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.

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.


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:

  • the details of the hash function (it is a derivative of P.J Weinberger hash function)
  • the lookup function which uses that hash function and a second function to deal with conflicts
  • the method for determining the size of the hash table

The first 2 elements are in LGPL copyrighted source code, the last is in GPL copyrighted source code.

Everything else is documented and can be written from scratch with no need for copyrighted material.


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.


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 derivative work? And could all this be a fair use of the copyrighted material?

1 Answer 1


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.

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.

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.

  • Thank your your answer. In my use case, nothing will be directly copied, at least because I will use a different language. What I need to get from the code is for example the size of the hash table is the next prime number greater than or equal to the 4 * n / 3 where n is the number of strings. There are not that much method to compute that code, even if written from scratch, my code will be quite similar to the original. So your answer let me think that code under GPL/LGPL cannot be ported to the Python library, sigh... Commented Dec 14, 2018 at 16:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .