PyMiniRacer icon indicating copy to clipboard operation
PyMiniRacer copied to clipboard

Clone a context

Open ibachar-es opened this issue 4 years ago • 1 comments

Is it possible to clone a context? My use case is that I have a context which is expensive to setup (need to eval a bunch of code). I then wish to use this context to run small code snippets. I wish to avoid the possibility of these small snippets causing errors in the context. Therefore, before running each snippet I want to clone the base context (assuming cloning we be much faster than creating new context and recompiling) and use the clone to run the snippet

System configuration

PyMiniRacer version: 0.2.0

Python version: 3.7.7

ibachar-es avatar Jun 24 '20 06:06 ibachar-es

Hi, it is not possible to clone a context directly. V8 provides a mechanism to "snapshot" an isolate and clone it which is more or less what you want to do, but it still comes at a significant cost. PyMiniRacer currently doesn't have such feature but I would gladly accept any contribution for it.

nizox avatar Jun 29 '20 08:06 nizox