brython-dev / brython

Brython (Browser Python) is an implementation of Python 3 running in the browser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Importing the `inspect` module takes much longer with version 3.12.1 than with version 3.11.3

epeios-q37 opened this issue · comments

Hi,

Following code displays in an alert box the time it takes to import the inspect module.

import browser, time

start = time.monotonic()

import inspect

browser.alert("Duration (ms): " + str(int((time.monotonic() - start)*1000)))

With version 3.12.1, it takes much longer than with version 3.11.3.

Open the following link and click on the Run button to see how long it takes with version 3.11.3:

https://faas.q37.info/brython/?version=3.11.3&code=import%20browser%2C%20time%0A%0Astart%20%3D%20time.monotonic()%0A%0Aimport%20inspect%0A%0Abrowser.alert(%22Duration%20(ms)%3A%20%22%20%2B%20str(int((time.monotonic()%20-%20start)*1000)))

Do the same thing but with the following link for version 3.12.1:

https://faas.q37.info/brython/?version=3.12.1&code=import%20browser%2C%20time%0A%0Astart%20%3D%20time.monotonic()%0A%0Aimport%20inspect%0A%0Abrowser.alert(%22Duration%20(ms)%3A%20%22%20%2B%20str(int((time.monotonic()%20-%20start)*1000)))

In the second case, it takes up to 10 seconds with my system for the alert box to be displayed.

Merci pour le signalement Claude !

It's likely because of an issue with the cache for modules in the standard distribution. Can you try with the latest development version, either with the GIT clone or with these scripts:

<script src="https://raw.githack.com/brython-dev/brython/master/www/src/brython.js"
        crossorigin="anonymous">
</script>
<script src="https://raw.githack.com/brython-dev/brython/master/www/src/brython_stdlib.js"
        crossorigin="anonymous">
</script>

Merci pour ce projet !
Désolé pour le message effacé ; j'ai fait une erreur ayant pour conséquence d'utiliser la version 3.11.3 en croyant utiliser la version de développement.

This is effectively a cache issue. Importation with version 3.11.3 is indeed as slow as with version 3.12.1 after clearing the caches, but much faster on subsequent launches, unlike version 3.12.1.
The development version behaves like version 3.11.3: slow when caches are cleared, much faster on subsequent launches.