Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gpython is a python interpreter written in go "batteries not included"

License

NotificationsYou must be signed in to change notification settings

go-python/gpython

Repository files navigation

Build StatuscodecovGoDocLicense

gpython is a part re-implementation, part port of the Python 3.4interpreter 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!)

gpython does not include many python modules as many of the coremodules are written in C not python. The converted modules are:

  • builtins
  • marshal
  • math
  • time
  • sys

Install

Download directly from thereleases page

Or if you have Go installed:

go install github.com/go-python/gpython

Objectives

gpython started as an experiment to investigate how hardporting Python to Go might be. It turns out that all those C modulesare a significant barrier to making gpython a complete replacementto CPython.

However, to those who want to embed a highly popular and known languageinto their Go application, gpython could be a great choice over lesscapable (or lesser known) alternatives.

Status

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 ("multi-context") execution

Speed hasn't been a goal of the conversions however it runs pystone atabout 20% of the speed of CPython. Aπ computation test runs quicker undergpython as the Go long integer primitives are likely faster than thePython ones.

@ncw started gpython in 2013 and work on is sporadic. If you or someoneyou know would be interested to take it futher, it would be much appreciated.

Getting Started

Theembedding example demonstrates how toeasily embed and invoke gpython from any Go application.

Of interest, gpython is able to run multiple interpreter instances simultaneously,allowing you to embed gpython naturally into your Go application. This makes itpossible to use gpython in a server situation where complete interpreterindependence is paramount. See this in action in themulti-context example.

If you are looking to get involved, a light and easy place to start is adding more convenience functions topy/util.go. Seenotes.txt for bigger ideas.

Other Projects of Interest

  • grumpy - a python to go transpiler

Community

You can chat with the go-python community (or which gpython is part)atgo-python@googlegroups.comor on theGophers Slack in the#go-python channel.

License

This is licensed under the MIT licence, however it contains code whichwas ported fairly directly directly from the CPython source code underthePSF LICENSE.

About

gpython is a python interpreter written in go "batteries not included"

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp