Coder Social home page Coder Social logo

nroot33 / gpython Goto Github PK

View Code? Open in Web Editor NEW

This project forked from go-python/gpython

0.0 1.0 0.0 1.02 MB

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

License: BSD 3-Clause "New" or "Revised" License

Python 16.07% Go 80.94% Yacc 2.01% Shell 0.07% C 0.07% Makefile 0.01% HTML 0.09% JavaScript 0.74%

gpython's Introduction

gpython

Build Status codecov GoDoc 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
  • interactive mode (REPL) (try online!)

It does not include very 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

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

Or alternatively if you have Go installed use

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.

Objectives

Gpython was written as a learning 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.

Status

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.

See the examples directory for some python programs which run with gpython.

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 Python ones.

There are many directions this project could go in. I think the most profitable would be to re-use the 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).

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.

Limitations and Bugs

Lots!

Similar projects

  • grumpy - a python to go transpiler

Community

You can chat with the go-python community (or which gpython is part) at [email protected] 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.

gpython's People

Contributors

ncw avatar corona10 avatar sbinet avatar raff avatar dodaek avatar hyeockjinkim avatar kellrott avatar kislenko-artem avatar mattheusv avatar sungmin-joo avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.