Skip to content

Multiple Interpreters #69

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

Closed
PythonLinks opened this issue Aug 10, 2019 · 5 comments
Closed

Multiple Interpreters #69

PythonLinks opened this issue Aug 10, 2019 · 5 comments

Comments

@PythonLinks
Copy link

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 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
Collaborator

@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 commented Aug 12, 2019 via email

@drew-512
Copy link
Contributor

drew-512 commented Feb 16, 2022

suggest close issue -- addressed w/ #158

@sbinet
Copy link
Member

sbinet commented Feb 22, 2022

fixed w/ #158.

@sbinet sbinet closed this as completed Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants