{"id":19097282,"url":"https://github.com/lycantropos/cfractions","last_synced_at":"2025-04-30T14:29:56.136Z","repository":{"id":57307072,"uuid":"368641812","full_name":"lycantropos/cfractions","owner":"lycantropos","description":"Python C API alternative to `fractions` module","archived":false,"fork":false,"pushed_at":"2025-04-28T18:56:20.000Z","size":340,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T14:29:52.373Z","etag":null,"topics":["fractions","python-c-extension"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lycantropos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-05-18T19:15:00.000Z","updated_at":"2025-03-31T18:25:36.000Z","dependencies_parsed_at":"2024-11-09T03:39:56.351Z","dependency_job_id":"e0b543d9-85cd-4fca-8d52-06ee66736d5a","html_url":"https://github.com/lycantropos/cfractions","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lycantropos%2Fcfractions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lycantropos%2Fcfractions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lycantropos%2Fcfractions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lycantropos%2Fcfractions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lycantropos","download_url":"https://codeload.github.com/lycantropos/cfractions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251721333,"owners_count":21632813,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fractions","python-c-extension"],"created_at":"2024-11-09T03:39:46.239Z","updated_at":"2025-04-30T14:29:56.104Z","avatar_url":"https://github.com/lycantropos.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"cfractions\n========\n\n[![](https://github.com/lycantropos/cfractions/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/lycantropos/cfractions/actions/workflows/ci.yml \"Github Actions\")\n[![](https://codecov.io/gh/lycantropos/cfractions/branch/master/graph/badge.svg)](https://codecov.io/gh/lycantropos/cfractions \"Codecov\")\n[![](https://img.shields.io/github/license/lycantropos/cfractions.svg)](https://github.com/lycantropos/cfractions/blob/master/LICENSE \"License\")\n[![](https://badge.fury.io/py/cfractions.svg)](https://badge.fury.io/py/cfractions \"PyPI\")\n\nSummary\n-------\n\n`cfractions` is a drop-in replacement for [`fractions` module](https://docs.python.org/library/fractions.html)\nwritten using [`Python C API`](https://docs.python.org/c-api/index.html).\n\nMain features are:\n- speed \u0026 memory efficiency compared to pure-`Python` counterpart,\n- full spectre of arithmetic \u0026 comparison operations,\n- `Python3.9+` support,\n- `PyPy` support (by falling back to `fractions.Fraction` proxy).\n\n---\n\nIn what follows `python` is an alias for `python3.9` or `pypy3.9`\nor any later version (`python3.10`, `pypy3.10` and so on).\n\nInstallation\n------------\n\nInstall the latest `pip` \u0026 `setuptools` packages versions\n```bash\npython -m pip install --upgrade pip setuptools\n```\n\n### User\n\nDownload and install the latest stable version from `PyPI` repository\n```bash\npython -m pip install --upgrade cfractions\n```\n\n### Developer\n\nDownload the latest version from `GitHub` repository\n```bash\ngit clone https://github.com/lycantropos/cfractions.git\ncd cfractions\n```\n\nInstall\n```bash\npython -m pip install -e .\n```\n\nUsage\n-----\n```python\n\u003e\u003e\u003e from cfractions import Fraction\n\u003e\u003e\u003e Fraction()\nFraction(0, 1)\n\u003e\u003e\u003e Fraction(1, 2)\nFraction(1, 2)\n\u003e\u003e\u003e Fraction(50, 100)\nFraction(1, 2)\n\u003e\u003e\u003e Fraction(0.5)\nFraction(1, 2)\n\u003e\u003e\u003e Fraction(1, 3) + Fraction(1, 6)\nFraction(1, 2)\n\u003e\u003e\u003e Fraction(3, 2) - 1\nFraction(1, 2)\n\u003e\u003e\u003e 1 - Fraction(1, 2)\nFraction(1, 2)\n\u003e\u003e\u003e Fraction(1, 3) * Fraction(3, 2)\nFraction(1, 2)\n\u003e\u003e\u003e Fraction(1, 3) / Fraction(2, 3)\nFraction(1, 2)\n\u003e\u003e\u003e Fraction(1, 6) * 3\nFraction(1, 2)\n\u003e\u003e\u003e Fraction(3, 2) / 3\nFraction(1, 2)\n\u003e\u003e\u003e str(Fraction(1, 2))\n'1/2'\n\n```\n\nDevelopment\n-----------\n\n### Bumping version\n\n#### Preparation\n\nInstall\n[bump2version](https://github.com/c4urself/bump2version#installation).\n\n#### Pre-release\n\nChoose which version number category to bump following [semver\nspecification](http://semver.org/).\n\nTest bumping version\n```bash\nbump2version --dry-run --verbose $CATEGORY\n```\n\nwhere `$CATEGORY` is the target version number category name, possible\nvalues are `patch`/`minor`/`major`.\n\nBump version\n```bash\nbump2version --verbose $CATEGORY\n```\n\nThis will set version to `major.minor.patch-alpha`.\n\n#### Release\n\nTest bumping version\n```bash\nbump2version --dry-run --verbose release\n```\n\nBump version\n```bash\nbump2version --verbose release\n```\n\nThis will set version to `major.minor.patch`.\n\n### Running tests\n\nInstall with dependencies\n```bash\npython -m pip install -e .[tests]\n```\n\nPlain\n```bash\npytest\n```\n\nInside `Docker` container:\n- with `CPython`\n  ```bash\n  docker-compose --file docker-compose.cpython.yml up\n  ```\n- with `PyPy`\n  ```bash\n  docker-compose --file docker-compose.pypy.yml up\n  ```\n\n`Bash` script:\n- with `CPython`\n  ```bash\n  ./run-tests.sh\n  ```\n  or\n  ```bash\n  ./run-tests.sh cpython\n  ```\n\n- with `PyPy`\n  ```bash\n  ./run-tests.sh pypy\n  ```\n\n`PowerShell` script:\n- with `CPython`\n  ```powershell\n  .\\run-tests.ps1\n  ```\n  or\n  ```powershell\n  .\\run-tests.ps1 cpython\n  ```\n- with `PyPy`\n  ```powershell\n  .\\run-tests.ps1 pypy\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flycantropos%2Fcfractions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flycantropos%2Fcfractions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flycantropos%2Fcfractions/lists"}