You can use:
1. **Cython**: Compile your Python code into C code, which can be linked against a shared library. Users will only see the API.
2. **SWIG** (Simplified Wrapper and Interface Generator): Generate a wrapper around your code to create a C interface that can be used by Python.
3. **Pydantic** or other Python frameworks: Use these libraries to create data models, schemas, or APIs without exposing the underlying implementation.
To further protect your IP:
* Use descriptive but non-descriptive names for functions and variables.
* Avoid using comments that might reveal implementation details.
* Consider using a code obfuscation tool like **Pyminifier** or **Obfuscatory**, which can make it harder to reverse-engineer your code.
However, keep in mind:
* Users may still be able to inspect the library's documentation, imports, and dependencies.
* They might use tools like `pip deb` or `pip freeze` to extract information about your library.