Skip to main content

Cythonize modelx models.

Project description

modelx-cython: Cythonize modelx models

Important: modelx-cython is currently highly experimental and is released only for early adopters with advanced software engineering skills to explore its capability.

What is modelx-cython?

modelx-cython is a Python package for cythonizing exported modelx models.

modelx Ecosystem

Usage

Suppose model in the code below is a modelx Model. The code creates a pure-Python model of model as a Python package named "Model_nomx" in the current directory.

>>> model.export("Model_nomx")

You need a config file and a sample file to translate the model to a Cythonized model and compile it. Create and name them config.py and sample.py respectively, and place them in the directory where Model_nomx is located.

Upon installing modelx-cython, the mx2cy command becomes available as an executable command. In a Python-enabled command prompt or shell, change the current directory with cd to where Model_nomx is located, and run:

mx2cy Model_nomx

This will create a Python package named "Model_nomx_cy", next to the original "Model_nomx".

Command

usage: mx2cy [-h] [--sample SAMPLE] [--spec SPEC | --no-spec] [--setup SETUP] [--translate-only | --compile-only]
             [--log-level LOG_LEVEL]
             model_path

Translate an exported modelx model into Cython and compile it.

positional arguments:
  model_path            Path to an exported modelx model to translate into Cython

options:
  -h, --help            show this help message and exit
  --sample SAMPLE       Path to a sample file to run for collecting type information (default: sample.py)
  --spec SPEC           Path to a spec file for setting parameters (default: spec.py)
  --no-spec             Skip the spec file (default: False)
  --setup SETUP         Path to a setup file for Cython (default: setup.py)
  --translate-only      Perform translation only (default: False)
  --compile-only        Perform compilation only (default: False)
  --log-level LOG_LEVEL
                        Logging level: NOTSET(0), DEBUG(10), INFO(20), WARNING(30), ERROR(40), CRITICAL(50) (default:
                        WARNING)

See Also

How to Install

To install modelx-cython, run the following command from your command prompt:

pip install modelx-cython

If you're on Anaconda, instead above install it from conda-forge:

conda install -c conda-forge modelx-cython

Requirements

modelx-cython requires Python 3.7+.

  • modelx v0.23.0+
  • Cython v3.0.0+
  • setuptools
  • libcst
  • MonkeyType

License

Copyright 2023-2025, Fumito Hamamura

modelx is free software; you can redistribute it and/or modify it under the terms of GNU Lesser General Public License v3 (LGPLv3).

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

modelx_cython-0.0.6.tar.gz (36.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modelx_cython-0.0.6-py3-none-any.whl (44.0 kB view details)

Uploaded Python 3

File details

Details for the file modelx_cython-0.0.6.tar.gz.

File metadata

  • Download URL: modelx_cython-0.0.6.tar.gz
  • Upload date:
  • Size: 36.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for modelx_cython-0.0.6.tar.gz
Algorithm Hash digest
SHA256 78cd2f7f60340eb9f56904cf23d10e0017bb66aff2b00a8b1a48e9429ad5154c
MD5 238e73b0fb921144de152f50ee33ae17
BLAKE2b-256 1554c058a5d357f058fb03f03e8a62249f083e7fe6b0998f283f4eefec2dec40

See more details on using hashes here.

Provenance

The following attestation bundles were made for modelx_cython-0.0.6.tar.gz:

Publisher: publish-to-pypi.yml on fumitoh/modelx-cython

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file modelx_cython-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: modelx_cython-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 44.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for modelx_cython-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b21f50d9a8e8fbcc08558727574fbcb63cc193eebaacd007cc25983e25df07c7
MD5 d9921c4ff2c61070fb27857299d45768
BLAKE2b-256 13eb84161fa0f50f9e27eb0a66f90d4d4a85fe98cfbab8b57cb3b864241b3f0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for modelx_cython-0.0.6-py3-none-any.whl:

Publisher: publish-to-pypi.yml on fumitoh/modelx-cython

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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