A robust tool to transpile Python source code into V(vlang) code.
A robust tool to transpile Python source code into V code.
This project bridges the gap between Python’s ease of development and V’s performance and safety.
# Installation
pip install .
# Transpile a file
py2v script.py
# Transpile a project recursively
py2v my_project/ --recursive
mypy (int, float, bool, str, lists, dicts, tuples, sets)if, for, while, match/case__init__:=), slice notationmath, json, random, os, sys, datetime, re and more| Section | Description |
|---|---|
| Installation | Requirements and installation from source |
| Usage | CLI options and usage examples |
| Supported Features | Complete list of supported Python features |
| Standard Library Mapping | Python to V standard library correspondence |
| LLM Comments (Russian) | Special //##LLM@@ comments for AI-assisted code review |
| Architecture | Internal structure of the transpiler |
| Development | Developer guidelines |
| Pydantic | Pydantic Support |
Python (input.py):
from math import sqrt
def fibonacci(n: int) -> list[int]:
"""Generate Fibonacci sequence."""
if n <= 0:
return []
elif n == 1:
return [0]
seq = [0, 1]
for i in range(2, n):
seq.append(seq[-1] + seq[-2])
return seq
if __name__ == "__main__":
print(fibonacci(10))
V (output.v):
import math
pub fn fibonacci(n int) []int {
// Generate Fibonacci sequence.
if n <= 0 {
return []Any{}
} else if n == 1 {
return [0]
}
mut seq := []int{cap: 2}
seq << 0
seq << 1
for i in 2..n {
seq.append(seq[-1] + seq[-2])
}
return seq
}
fn main() {
// if __name__ == '__main__':
println('${fibonacci(10)}')
}