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.8.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.8-py3-none-any.whl (44.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for modelx_cython-0.0.8.tar.gz
Algorithm Hash digest
SHA256 643e5e01c934d3e22cd79e0ceac5f1bdbc06f6f68c4fe172677be4b4851b3a98
MD5 242d7124be8c57b45ff8b156780a6376
BLAKE2b-256 09d5744ccc36c0b8465fbf6c3cc86782b614874c4184f39e478c03f603dadc60

See more details on using hashes here.

Provenance

The following attestation bundles were made for modelx_cython-0.0.8.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.8-py3-none-any.whl.

File metadata

  • Download URL: modelx_cython-0.0.8-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.13.7

File hashes

Hashes for modelx_cython-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 2988d9f06f4a5d23b66ed8bcf1682a7f4795929930520fe8f6d79f3401b34475
MD5 21da2006fffefb7a8d7046713107765e
BLAKE2b-256 08e23e4431f823021793016083c7c1be691eaab9decef2ad26ec597285ac9790

See more details on using hashes here.

Provenance

The following attestation bundles were made for modelx_cython-0.0.8-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