Visitar URL original
Multiple Interpreters · Issue #69 · go-python/gpython · GitHub
The Wayback Machine - https://web.archive.org/web/20200910210615/https://github.com/go-python/gpython/issues/69
Skip to content
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

Multiple Interpreters #69

Open
PythonLinks opened this issue Aug 10, 2019 · 3 comments
Open

Multiple Interpreters #69

PythonLinks opened this issue Aug 10, 2019 · 3 comments

Comments

@PythonLinks
Copy link

@PythonLinks PythonLinks commented Aug 10, 2019

Here is the PEP for multiple interpreters.
https://www.python.org/dev/peps/pep-0554/

It was rumored to be in Python3.7. Next I heard it would be in 3.8, then 3.9, now the Pep says provisional in 3.8, and they will make a decision about 3.9. I would not be surprised if multiple interpreters shipped first in gPython.

And I suspect that the cPython version will be one interpreter per OS thread. With gPython we could have thousands of interpreters.

I should also mention stackless.
https://github.com/stackless-dev/stackless/wiki

And finally the documents say that this is 1/5 th as fast as cPython. But I can easily get a server with 32 cores. And many applications now have little processing and lots of network I/O.

I just wonder what the killer app for this would be? It would be great to have a game, where a conference programming competition would be to win the multiplayer game, much like the snake competition at some recent Python conferences.

Warm Regards
Christopher Lozinski

@ncw
Copy link
Collaborator

@ncw ncw commented Aug 11, 2019

My plan is to implement a "go" modules with some low level support for go facilities

  • go routines
  • channels
  • mutex
  • select (maybe)

This could then be used to make some higher level constructs eg the threading library.

My plan is to make a new interpreter for each goroutine so they can run together without locking. I'm not sure that is exactly the level at which the PEP you linked works but it might be!

Each goroutine would be able to access its own things without locking but accessing shared things would need locking.

I have a plan for how to implement the "go" module somewhere... It involves making some new "special functions" in the interpreter

gpython/vm/eval.go

Lines 1582 to 1591 in fff175c

// As py.Call but takes an intepreter Frame object
//
// Used to implement some interpreter magic like locals(), globals() etc
func callInternal(fn py.Object, args py.Tuple, kwargs py.StringDict, f *py.Frame) (py.Object, error) {
if method, ok := fn.(*py.Method); ok {
switch x := method.Internal(); x {
case py.InternalMethodNone:
case py.InternalMethodGlobals:
return f.Globals, nil
case py.InternalMethodLocals:

@corona10
Copy link
Member

@corona10 corona10 commented Aug 11, 2019

@ncw If we implement this feature based on goroutine, I think this feature can be unique to gpython. I like this issue.

@PythonLinks
Copy link
Author

@PythonLinks PythonLinks commented Aug 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.