Z3dPyFast - ZackWilde27/Z3dPy GitHub Wiki

Z3dPy includes an extension that replaces the more complicated math functions with C++ versions that run faster.

import z3dpy as zp

# If you're using 0.3.2 and below, it's on by default.
zp.Fast()

It straight-up overwrites the Python functions, so the coding experience is identical, and all internal functions will switch over. The only caveat being that you can't go back to pure Python without resetting.

Installing

If you downloaded -win.zip or -deb.zip from the releases, z3dpyfast is already installed.

or

In the zpfast folder, find the version for your OS and copy it to the root folder, alongside z3dpy.py (From the repo it's the z3dpyfast folder)

Screenshot 2023-06-19 123941

Screenshot 2023-06-19 124044

Compiling

I've already compiled versions using Windows 11, and Linux Mint, but if you are running something else, you may need to compile it yourself.

In the same directory as OGScript.cpp, create a new python file called setup.py

setup.py should look like this:

from setuptools import setup, Extension

sfc_module = Extension('z3dpyfast', sources = ['OGScript.cpp'])

setup(
    name="z3dpyfast",
    version="0.2.0",
    description="Z3dPy C++ Functions",
    ext_modules=[sfc_module]
)

Next, open a terminal in the same directory and run this command:

python3 setup.py install

The way you invoke python may differ on your OS, but the command is the same.

If you get an error during building, it could be that setuptools has a different name in your version of Python

On completing, z3dpyfast will be installed in the global site-packages, so z3dpy should have no trouble finding it.

The extension's location should be displayed during install, if for some reason it's not detected.