Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 105
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
fc66b7fd10c35f2161b71247ec429a7527190a8988c51644e7f7d213708bb7ea24425675d8743d5fb8e8269bdc04db9c6553d05db7fd1c298f3a1045ebaf66d423190b33c266efca7611569475a9c5f1f6372aee4af4f90aec59f874f1a198fa662226fb9aa8614aeb86531c6f71b96177a79546bba7da46d105266fad2395afd7b319edb706a2eae8d4d586d475e676afac99931c346a7ce4bbc1f88099f02cf185e3a4afbec34edbd54d871a5604634823c6a0c11e624283661c7830bb98aa836b1018f2602bce25e3bb9421b6b92aed8a96515eaf62f2b73bdba628033615681abf2750855699bcb400cc76509afb2d37d2a8d9ba7db8061e42c8168c3372b7e1ab3821b4b170f0d2b68b9f6759023b0c77716505755d02d6b3eFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -8,3 +8,6 @@ __pycache__ | ||
| cover.out | ||
| /junk | ||
| /dist | ||
| examples/embedding/embedding | ||
| builtin/testfile | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| // Use IntelliSense to learn about possible attributes. | ||
| // Hover to view descriptions of existing attributes. | ||
| // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| { | ||
| "name": "Launch file", | ||
| "type": "go", | ||
| "request": "launch", | ||
| "mode": "debug", | ||
| "program": "${file}" | ||
| }, | ||
| { | ||
| "name": "examples/embedding", | ||
| "type": "go", | ||
| "request": "launch", | ||
| "mode": "auto", | ||
| "program": "${workspaceFolder}/examples/embedding", | ||
| "cwd": "${workspaceFolder}/examples/embedding", | ||
| "args": [ | ||
| "mylib-demo.py" | ||
| ], | ||
| }, | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -5,18 +5,20 @@ | ||
| [](https://godoc.org/github.com/go-python/gpython) | ||
| [](https://github.com/go-python/gpython/blob/master/LICENSE) | ||
| gpython is a part re-implementation / part port of the Python 3.4 | ||
| interpreter to the Go language, "batteries not included". | ||
| It includes: | ||
| * runtime - using compatible byte code to python3.4 | ||
| * lexer | ||
| * parser | ||
| * compiler | ||
| gpython is a part re-implementation, part port of the Python 3.4 | ||
| interpreter in Go. Although there are many areas of improvement, | ||
| it stands as an noteworthy achievement in capability and potential. | ||
| gpython includes: | ||
| * lexer, parser, and compiler | ||
| * runtime and high-level convenience functions | ||
| * multi-context interpreter instancing | ||
| * easy embedding into your Go application | ||
| * interactive mode (REPL) ([try online!](https://gpython.org)) | ||
| It does not include very many python modules as many of the core | ||
| gpython does not include many python modules as many of the core | ||
| modules are written in C not python. The converted modules are: | ||
| * builtins | ||
| @@ -27,53 +29,52 @@ modules are written in C not python. The converted modules are: | ||
| ## Install | ||
| Gpython is a Go program and comes as a single binary file. | ||
| Download the relevant binary from here: https://github.com/go-python/gpython/releases | ||
| Download directly from the [releases page](https://github.com/go-python/gpython/releases) | ||
| Or alternatively if you have Go installed use | ||
| Or if you have Go installed: | ||
| go get github.com/go-python/gpython | ||
| and this will build the binary in `$GOPATH/bin`. You can then modify | ||
| the source and submit patches. | ||
| go install github.com/go-python/gpython | ||
| ## Objectives | ||
| Gpython was written as a learning experiment to investigate how hard | ||
| gpython started as an experiment to investigate how hard | ||
| porting Python to Go might be. It turns out that all those C modules | ||
| are a significant barrier to making a fully functional port. | ||
| are a significant barrier to making gpython a complete replacement | ||
| to CPython. | ||
| ## Status | ||
| However, to those who want to embed a highly popular and known language | ||
| into their Go application, gpython could be a great choice over less | ||
| capable (or lesser known) alternatives. | ||
| The project works well enough to parse all the code in the python 3.4 | ||
| distribution and to compile and run python 3 programs which don't | ||
| depend on a module gpython doesn't support. | ||
| ## Status | ||
| See the examples directory for some python programs which run with | ||
| gpython. | ||
| gpython currently: | ||
| - Parses all the code in the Python 3.4 distribution | ||
| - Runs Python 3 for the modules that are currently supported | ||
| - Supports concurrent multi-interpreter execution ("multi-context") | ||
| Speed hasn't been a goal of the conversions however it runs pystone at | ||
| about 20% of the speed of cpython. The pi test runs quicker under | ||
| gpython as I think the Go long integer primitives are faster than the | ||
| about 20% of the speed of CPython. The [π test](https://github.com/go-python/gpython/tree/master/examples/pi_chudnovsky_bs.py) runs quicker under | ||
| gpython as the Go long integer primitives are likely faster than the | ||
| Python ones. | ||
| There are many directions this project could go in. I think the most | ||
| profitable would be to re-use the | ||
| [grumpy](https://github.com/grumpyhome/grumpy) runtime (which would mean | ||
| changing the object model). This would give access to the C modules | ||
| that need to be ported and would give grumpy access to a compiler and | ||
| interpreter (gpython does support `eval` for instance). | ||
| @ncw started gpython it in 2013 and work on is sporadic. If you or someone | ||
| you know would be interested to take it futher, it would be much appreciated. | ||
| ## Getting Started | ||
| I (@ncw) haven't had much time to work on gpython (I started it in | ||
| 2013 and have worked on it very sporadically) so someone who wants to | ||
| take it in the next direction would be much appreciated. | ||
| 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. | ||
Comment on lines
+66
to
+67
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather prefer having the | ||
| ## Limitations and Bugs | ||
| Importantly, gpython is able to run multiple interpreter instances simultaneously, | ||
| allowing you to embed gpython naturally into your Go application. This makes it | ||
| possible to use gpython in a server situation where complete interpreter | ||
| independence is an absolute requirement. See this in action in the [multi-context example](https://github.com/go-python/gpython/tree/master/examples/multi-context) | ||
| If you are looking to get involved, a light and easy place to start is adding more convenience functions to [py/util.go](https://github.com/go-python/gpython/tree/master/py/util.go). See [notes.txt](https://github.com/go-python/gpython/blob/master/notes.txt) for bigger ideas. | ||
| Lots! | ||
| ## Similar projects | ||
| ## Other Projects of Interest | ||
| * [grumpy](https://github.com/grumpyhome/grumpy) - a python to go transpiler | ||
| @@ -86,5 +87,5 @@ or on the [Gophers Slack](https://gophers.slack.com/) in the `#go-python` channe | ||
| ## License | ||
| This is licensed under the MIT licence, however it contains code which | ||
| was ported fairly directly directly from the cpython source code under | ||
| was ported fairly directly directly from the CPython source code under | ||
| the [PSF LICENSE](https://github.com/python/cpython/blob/master/LICENSE). | ||
Uh oh!
There was an error while loading. Please reload this page.
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.