From 6681e37c4986be1a2d255fd9c1b22a72aecc8507 Mon Sep 17 00:00:00 2001 From: KuchikiRenji Date: Wed, 4 Feb 2026 00:45:58 +0900 Subject: [PATCH] update README.md for SEO and user-friendly --- README.md | 141 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 89 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 78e5894..1d015a9 100644 --- a/README.md +++ b/README.md @@ -1,53 +1,90 @@ -# Rewriting a Python Script in Rust - -### PURPOSE - -The purpose of this project is to rewrite an existing Python script used for data processing in the Rust programming language. The main goals of this project are as follows: -1. Code Migration: Rewrite the Python script in Rust, ensuring it performs the same data processing tasks. -2. Performance Enhancement: Evaluate the improvements in terms of execution speed and resource usage after the migration to Rust. - -*** - -### PROCESS - -To achieve the objectives of this project, the following steps are taken: -1. Script Selection: Selected an existing Python script for data processing. This script served as a suitable candidate for migration to Rust. -2. Rewrite in Rust: Rewrote the selected Python script in Rust while maintaining the same functionality. This step involved translating the Python code into idiomatic Rust code. -3. Testing and Debugging: Tested the Rust script to ensure it produces the expected results. Debugged and fixed any issues that arose during the migration. -4. Benchmarking: Conducted performance benchmarking tests to evaluate the improvements in execution speed and resource usage achieved by the Rust version of the script. -5. Documentation: Documented the entire process, including the code migration and performance benchmarking. Created a performance comparison report in Markdown format (README). - -*** - -### Commands to Run the Repo - -To run the project, you can use the Makefile and follow these commands: -1. ``` - # To install the required the python packages - make install - ``` -2. ``` - # To check code style - make lint - ``` -3. ``` - # To run tests - make test - ``` -4. ``` - # To format the code - make format - ``` -5. ``` - # To extract data - make extract - ``` -6. ``` - # To tranform data - make transform_load - ``` -7. ``` - # To query data - make query - ``` +# Rewriting a Python Script in Rust | Python to Rust Migration Example +**Migrate Python data-processing code to Rust for better performance.** This repository demonstrates a full Python-to-Rust rewrite: same logic (factorial), testing, linting, and benchmarking—useful for learning Rust migration and comparing Python vs Rust speed. + +--- + +## What This Project Does + +This project **rewrites an existing Python script in Rust** and compares performance. It is a practical example of: + +- **Code migration** — Translating a Python data-processing script into idiomatic Rust while keeping behavior identical. +- **Performance comparison** — Measuring execution speed and resource usage of the Rust version vs the Python version. + +Use this repo to learn **how to rewrite Python in Rust**, see **Rust vs Python performance** on a small workload, and follow a **Python to Rust migration** workflow with tests and tooling. + +--- + +## Quick Start + +**Prerequisites:** [Rust](https://www.rust-lang.org/tools/install) (and optionally Python 3 for the original script). + +```bash +# Format, lint, test, and run the Rust program +make format +make lint +make test +make run +``` + +**Run the Python version:** + +```bash +make python_install # install Python deps +make python_test # run tests +make python_format # format with Black +make python_lint # lint with Ruff +``` + +--- + +## Project Structure + +| Path | Purpose | +|------|--------| +| `main.py`, `mylib/` | Original Python script and library | +| `src/main.rs`, `src/lib.rs` | Rust equivalent (factorial logic) | +| `Makefile` | Commands for Rust and Python (format, lint, test, run) | +| `Cargo.toml` | Rust project and dependencies | + +--- + +## How the Migration Was Done + +1. **Script selection** — A small Python script (factorial/data-style processing) was chosen as the migration target. +2. **Rewrite in Rust** — The script was reimplemented in Rust with the same behavior. +3. **Testing and debugging** — Tests and manual checks ensure Rust output matches Python. +4. **Benchmarking** — Execution time and resource usage are compared between Python and Rust. +5. **Documentation** — Process and results are documented (including this README). + +--- + +## Makefile Commands + +| Command | Description | +|--------|-------------| +| `make format` | Format Rust code (`cargo fmt`) | +| `make lint` | Lint Rust code (Clippy) | +| `make test` | Run Rust tests | +| `make run` | Run the Rust binary | +| `make release` | Build release binary | +| `make python_install` | Install Python dependencies | +| `make python_test` | Run Python tests (pytest) | +| `make python_format` | Format Python with Black | +| `make python_lint` | Lint Python with Ruff | + +--- + +## Author & Contact + +**KuchikiRenji** + +- **Email:** [KuchikiRenji@outlook.com](mailto:KuchikiRenji@outlook.com) +- **GitHub:** [github.com/KuchikiRenji](https://github.com/KuchikiRenji) +- **Discord:** `kuchiki_renji` + +--- + +## License + +See [LICENSE](LICENSE) in this repository.