-
Notifications
You must be signed in to change notification settings - Fork 95
Multi-context execution (py.Context) #144
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
Conversation
Liking the your CI scripts! Added two more commits that addressed those tests not passing |
thanks. it's quite a large PR :) |
Hi friend. You'll see that much of the code is just additional helper/utility code (as well as the couple inner core changes relating to In the coming months, I will be using gypthon to power a Go-based UI runtime that "serves" a Unity client UI. The Unity client runs a 2D physics-based UI and embeds the Go process. This will power the UI for this particle research suite we are developing... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a very first pass: I see there are a bunch of files which have a 0644
-> 0755
chmod
change.
could this be reversed?
(I don't think this brings anything to these files. or does it?)
a naive question: do we expect multiple py.Ctx
implementations? wouldn't be easier to start with just a concrete Ctx
in py
?
also: there are a couple of fixes which are useful to have at some point but aren't needed for the multi-context change. could these be part of another PR?
thanks.
also, it would be great to have an idea of the loss (probably?) of performances wrt "single context" execution. |
Co-authored-by: Sebastien Binet <[email protected]>
Co-authored-by: Sebastien Binet <[email protected]>
Co-authored-by: Sebastien Binet <[email protected]>
Love all the CI stuff you're adding, awesome! The items I'm working on in the coming days are a README rev, a well documented embedded example (huge for newcomers), and the single vs multi ctx benchmark as you suggested. I think gpython as a viable, reliable embedded interpreter solution has very high potential. Something as potent, easy, and fast to embed as Lua, but in general, devs don't ever want to choose that b/c they don't want to tell their users to have to learn I've heard many big cats often quip "the second most popular language in the world", reflecting that when it comes to non-developers (finance, science), Python has the best learning curve and those users typically already have some python experience. Also, many of those types want to grow their python skills b/c they see it show up all over their career. So I suspect this could be a big theme, now we are in world awash in interpreters that are basically only interesting to professional developers. The gpython multi-context additions for this physics research group I mentioned are working out very well and seem to "complete" gpython for real world Go applications. I would love to remind you and @ncw what a huge freaking achievement running any python 3 in Go is, and that gpython's potential is not to be underestimated as a leading Go embedding option. Or perhaps I see no reason why Google would not want to donate a summer's worth of resources to gpython if that is something beneficial to gpython. Drew |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the update.
but, before going further, could we try to address the "single-thread before/after-context" benchmarking issue?
then I'd like to merge this PR in, so as to reduce the amount of reviewing work.
thanks a lot.
store *py.ModuleStore | ||
opts py.ContextOpts | ||
closeOnce sync.Once | ||
closing bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is closing
that useful?
it doesn't seem to be really used as of yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intent is that Close() can be use reliably and easily, so multiple concurrent Close() support seems important. And when it comes at no allocation cost, that makes sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not disputing the fact that Close()
is useful, but AFAICT closing
is accessed twice (once initialized with false
, then modified to true
) but its value isn't used much otherwise.
Indeed! :D Good suggestions, btw. Commits coming in by the end of this weekend is a documented, real-world embedding example, readme edits, and that benchmark. |
I'll switch to do and commit that benchmark first -- just had been putting that off, waaah. |
@sbinet for the pre-context vs with-context benchmarks you raised, I'm not clear on what the path is. I am getting that you want a PR that does bench X on gpython before Questions:
Thanks. |
Hi everyone! At this point I am holding off on any new work on my fork and awaiting guidance on anything further. I am happy to take feedback and @sbinet please let me know on my questions above regarding bench comparison. In summary: analysis of the Aside from readme or embedded example edits, I recommend we merge and celebrate this exciting step forward. A lot of people will find this multi-context capability exciting and recognize what it unlocks! |
Big thanks to everyone has helped make gpython happen over the years -- though it has been some time! @ncw it would be great to get any feedback or your blessing on any of the code or the README. Otherwise, @sbinet has been making great suggestions and I think we're in great shape to almost ready to merge! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last nitpicks.
I'd prefer to keep:
- 7d2a8d9 (print kwargs)
- ba7db80 (kwargs)
- 61e42c8 (embedding)
out of this PR (and have those in dedicated PRs)
also, it would be great if you could create a dedicated branch for these PRs (easier on the review process).
could you send another PR against go-python/licence adding yourself to the AUTHORS
and/or CONTRIBUTORS
file?
(then, once the multi-context
PR is validated, I'll merge the licence one and the multi-context
one)
thanks.
@@ -0,0 +1,26 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove this file.
The [embedding example](https://github.com/go-python/gpython/tree/master/examples/embedding) demonstrates how to | ||
easily embed and invoke gpython from any Go application. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather prefer having the embedding
stuff be part of another PR.
return nil | ||
} | ||
|
||
// LoadIntsFromList extracts a list of ints contained given a py.List or py.Tuple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// LoadIntsFromList extracts a list of ints contained given a py.List or py.Tuple | |
// LoadIntsFromList extracts a list of ints contained in the provided py.List or py.Tuple |
store *py.ModuleStore | ||
opts py.ContextOpts | ||
closeOnce sync.Once | ||
closing bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not disputing the fact that Close()
is useful, but AFAICT closing
is accessed twice (once initialized with false
, then modified to true
) but its value isn't used much otherwise.
Co-authored-by: Sebastien Binet <[email protected]>
Co-authored-by: Sebastien Binet <[email protected]>
Co-authored-by: Sebastien Binet <[email protected]>
Co-authored-by: Sebastien Binet <[email protected]>
Co-authored-by: Sebastien Binet <[email protected]>
superseded by #158. |
Hi Seb, it's a been a couple months but things are well here.
With this PR, I am pleased to share gpython with multi-context execution! Check out
type Context interface
andvm/vm_test.go
for a quick start.My intention with this PR is get feedback from you on what you want me to alter or massage so that you are satisfied. I am totally open if you want me to shift, rename, or organize code in ways that you would prefer, so kindly please just let me know. I think many will be highly interested in a multi-ctx gpython (as many have asked for it as you already know).
So if you like things as they are, you can merge this PR. Otherwise, just give me a list of things you want changed and I'll resubmit a new PR with that. Or, perhaps merge this PR as is, insert edits as you see fit, tag it into a new release and version, and then I will follow your lead and ditch my fork and we can be on our way. :)
We are definitely using gpython here for our classified particle research project and would love to join forces with you on maintaining gpython. I think it is highly reasonable, especially with this PR, that gpython is picked up (sponsored) since it serves the Google, Python, and Go communities quite uniquely.