Does anyone know Cython?

Hello,

Does anyone use that ? Can that be usefull for WPFs ? Is a pythoncode even to handle with that ?
Or is this even out of range regarding pyRevit.

https://cython.readthedocs.io/en/latest/index.html
https://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html

As you can see from the overview page

[Cython] is a programming language that makes writing C extensions for the Python language as easy as Python itself.

It is completely out of pyRevit scope, and it has nothing to do with c# (and .NET in general), so it’s no use for WPF (I’m curious, how did you make that connection?)

To explain a bit more: C, C++ and C# are different programming languages, and while C and C++ are compiled to machine code, so they don’t need anything else to run (if they dont use other libraries as dependencies, obviously), C# (and the other .NET languages such as VB.NET and F#) compile to an intermediate language that is then run inside a VM (thats why you need the dotnet framewotk installed on your pc).
Since Revit API is built in .NET, you would want to stay as close as that framework and supported languages. IronPython is the .NET equivalent of the original Python (which is written in C), and unfortunately can’t leverage C extensions because of the way it is written.
The only way (that I know of) to run python C extensions in .NET is to use python.net, the library that pyRevit uses for the CPython engines, bu it still needs to be updated and polished (the current version is pretty unusable).

So, to your point: if you need performance, just write C# code directly, otherwhise don’t bother trying cython :wink:

1 Like