On 7/6/15, Pierre Quentel <
pierre....@gmail.com> wrote:
> Le lundi 6 juillet 2015 04:25:27 UTC+2, Olemis Lang a écrit :
>>
>> I've been trying to figure this out for days but I have no clue yet .
>> Could anybody please provide any hints about how js contexts work ? Am
>> I missing something obvious in my reasoning below ?
>>
[...]
>
> Olemis,
>
> I have started working on this. We must test precompiling to see if it
> actually improves import time, although I'm not sure of the result.
>
Ok . I'll reread this thread later today and get something done .
Everything I've done (on this direction) is published in
olemis/t222_import_pyc branch in my fork [1]_ .
> In the latest commits I have added 2 files,
I'll take a look into this in a while .
[...]
>
> Then I copy saved.js to /libs/
JFTR I'd prefer to publish these precompiled files at a different path .
[...]
> (I
> told you it was experimental ;-)
>
[...]
understood
> After that, I can import the module by "import saved" :
>
> Brython 3.2.1 on Netscape 5.0 (Windows)
>>>> import saved
>>>> saved.datetime.now()
> datetime.datetime(2015, 7, 6, 9, 28, 34, 226000)
>>>>
>
> At this stage it's hard to tell how much faster it is to load saved than
> datetime, because they import other scripts that should also be
> precompiled.
>
> An obvious drawback of this approach is the size of the precompiled file :
> 74 kB becomes 330 kB minified (saved.js is actually bigger) ie between 4
> and 5 times bigger.
>
This is for devs to decide , and IMO it's just a matter of what's the
most important resource CPU vs disk space vs download time .
> Do you think you can build on these scripts to precompile all the files in
> stdlib ?
>
I'll tell you once I review this in more detail , but looks like a
good starting point .
[...]
.. [1]
https://github.com/olemis/brython/tree/olemis/t222_import_pyc