Skip to main content

R to Python transpiler

Project description

📜 What is Rhyton

Rhyton is a type of ancient Greek drinking vessel that is in the shape of an animal's head or horn and has a hole in the bottom for pouring the liquid. It was often used in religious ceremonies or feasts.

The name came after combination of language names: R and Python

This library helps you to move R codebase to Python. Right now it supports conversion of math equations, expressions, conditions, function definitions and calls

🧲 Installation

The project is published on PyPi, so you can install it via pip

$: pip install rhyton

🚀 Launch

Use transpile or transpile_file to translate your R code

from rhyton import transpile, transpile_file

transpile('x <- 7') # returns transpiled string

# or

transpile_file(
  in_path='<path to your R file>.r', 
  out_path='<Path to generated Python file>.py'
)

🛠 How it works

Rhyton uses tree-sitter under the hood, to compute AST (Abstract Syntax Tree), after that it converts it to new AST that is valid for Python. After that it generates a code, using ast module and astor

📊 Feature plan

  • ✅ Add tree parsers

  • ✅ Semantic analysis for AST

    • ✅ Statements and expressions
    • ✅ Math operations
    • ✅ Conditions: if, else
    • ✅ Function definitions
    • ✅ Function calls
    • ❌ Cycles while and for
    • ❌ Arrays and operations
    • ❌ Function analogs
    • ❌ Import statements
    • ❌ Nested transpilation
  • ✅ Package demo publication

  • ✅ Project site

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rhyton-0.0.4.tar.gz (6.3 kB view hashes)

Uploaded Source

Built Distribution

rhyton-0.0.4-py3-none-any.whl (6.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page