[Python-ideas] Use lazy loading with hashtable in python gettext module

Serge Ballesta s-ball at laposte.net
Tue Dec 18 13:20:23 EST 2018


Hi!

>...  >     I use gettext quite extensively. I use Python's msgfmt to generate
> .mo files. I also use Django's compilemessage; I don't know what it uses
> internally, it could be an independent implementation or Python's msgfmt.
> 

Never used Django's implementation and I do not know its features.
I'll try to have a look to have a more exhaustive context.

>> ...
>> Remaining problems:
>> - I had to read GPL copyrighted code to find the undocumented features. I have of course wrote my own code from scratch, but may I use an Apache Free License 2.1 on it?
> 
>     You should ask a lawyer and I am not. But my understanding is that
> you can borrow ideas from a GPL-protected code without contaminating
> your code with GPL. You cannot copy code -- that makes your code GPL'd >

That is one of the reasons I have described here what I have done. I 
believe that it is correct, but I would be glad to have more experienced 
people's advice.

>> - the current code for gettext loads everything from the mo file and immediately closes it. My own code keeps the file opened to be able to access it with the mmap module. There could be use case where first option is better
> 
>     There is the third option -- open and close the file. I'd prefer the
> option as file descriptors are precious resources limited in supply.
>     There is a twist though. The file could be replaced while closed so
> you have to find a way to verify the was replaced and reread the has
> table from it. Perhaps checking timestamp of the file (date/time of the
> last modification) is enough.
> 

Yeah, the problem is there: file descriptors are a scarce resource, but 
opening a file is a costly operation. Here again that's why I considere 
an option to let the library users choose according to their own use case.

Serge


More information about the Python-ideas mailing list