Is there any tool or way in which I can convert or translate python code to c# code?
Python code can make calls directly into C modules. Those C modules can be either generic C libraries or libraries built specifically to work with Python. Cython generates the second kind of module: C libraries that talk to Python's internals, and that can be bundled with existing Python code.
Nuika (open source on GitHub) compiles Python to C++ code, which can then be executed in-place or packaged up as a stand-alone file for redistribution. Unlike some other replacements for existing Python interpreters, it claims full compatibility with all the language constructs in Python 2.6, 2.7, 3.2, and 3.3.
The Basics of CythonThe Cython compiler will convert it into C code which makes equivalent calls to the Python/C API. But Cython is much more than that, because parameters and variables can be declared to have C data types.
Although C remains the master of speed in general, PyPy can beat C in some cases. “If you want your code to magically run faster, you should probably just use PyPy.” PyPy is less effective when our program is fast anyway or when most of the runtime is spent for calls to non-python libraries.
There is an opensource tool that may be useful for conversion of Python to C#:
https://github.com/uxmal/pytocs
the sample conversions in that page look promising
Hm, wouldn't it be wiser to reuse the existing Python code base via IronPython, for example?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With