-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initialize stateless context #369
Comments
did a quick test using criterium: (ns user
(:require [criterium.core :as cc]
[sci.core :as sci]
[sci.impl.interpreter :as scii]
[sci.impl.opts :as scio]))
;; 25µs
(cc/quick-bench (sci/eval-string "(+ 1 1)" nil))
(def ctx (update (scio/init nil) :env deref))
;; 13µs
(cc/quick-bench (scii/eval-string* (update ctx :env atom) "(+ 1 1)")) |
@ikitommi Note that |
Implemented as follows: In a multi-user environment it can be useful to give each user their own (def forked (sci/fork sci-ctx))
(sci/eval-string* forked "(def forked 1)")
(sci/eval-string* forked "forked") ;;=> 1
(sci/eval-string* sci-ctx "forked") ;;=> Could not resolved symbol: forked |
Sometimes it's desirable to re-use the same set of options in
eval-string
for performance reasons, like you can do witheval-string*
but without the statefulness. It might be nice to offer an API around this.This can be achieved right now with:
The text was updated successfully, but these errors were encountered: