3 Star 0 Fork 0

mirrors_go-python/gpython

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

gpython

Build Status codecov GoDoc License

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!)

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

  • builtins
  • marshal
  • math
  • time
  • sys

Install

Download directly from the releases page

Or if you have Go installed:

go install github.com/go-python/gpython

Objectives

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 gpython a complete replacement to CPython.

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.

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 at about 20% of the speed of CPython. A π computation test runs quicker under gpython as the Go long integer primitives are likely faster than the Python ones.

@ncw started gpython 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

The embedding example demonstrates how to easily 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 it possible to use gpython in a server situation where complete interpreter independence is paramount. See this in action in the multi-context example.

If you are looking to get involved, a light and easy place to start is adding more convenience functions to py/util.go. See notes.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) at go-python@googlegroups.com or on the Gophers Slack in the #go-python channel.

License

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

Copyright ©2015 The go-python Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the gonum project nor the names of its authors and contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

暂无描述 展开 收起
README
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_go-python/gpython.git
git@gitee.com:mirrors_go-python/gpython.git
mirrors_go-python
gpython
gpython
main

搜索帮助