Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i have been working on a project on python for physics, using enthought canopy, i wished to enhance it by modifying it to a cython code. Could someone pleases tell me how to rewrite a python to cython codes in canopy? or do i need a separate software?
Just to add, it's probably better to use libraries which already incorporate Cython. NumPy for example, has virtually any array handling you can think of and has been optimized around things like matrix multiplication. Smart people have already done the work for you, so see if you can get that module to do what you need then as a last resort rewrite your code using Cython.
The Canopy Python distribution is bundled with Cython. However to use it, you will need a C compiler on your machine, which you may or may not already have. The Cython documentation has a good overview of Cython basics, including a brief description of where to get/find a C compiler for you operating system.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have been searching for the way to call Python from MATLAB on Google and YouTube. However, I got confused due to the many ways of doing so.
I have a Python library DESlib downloaded. I have a program from MATLAB that needs that library to perform dynamics classifier selection. No one has developed such a library for MATLAB. I can only found for Python.
So, how I do that call this library from MATLAB?
If your MATLAB version is new enough (the following definitely works on R2019a), MATLAB has builtin support for calling python functions.
Say module is your python library that you downloaded and you want to use a function func in that module, all you need to do is just
py.module.func(<arguments>)
See here for more details.
module has to be in the python search path, otherwise add it as detailed here
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I was wondering what language are windows programs coded in? Can a python program run on windows if the computer doesn't have python installed?
I would recommend reading into this:
https://en.wikipedia.org/wiki/Portable_Executable
An EXE is a bundle of machine code. Take a look in a hex editor and grab an opcode manual. You probably won't be able to make sense of it without a lot of studying, but they're basically micro instructions.
To your other question, though. Yes, you can make an exe from a Python script. This works by bundling the python runtime with the script itself. Take a look at pyinstaller:
http://www.pyinstaller.org/
EDIT: As pointed out in the comments, use pyinstaller instead of py2exe. It is more actively maintained.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I've read several threads about some of the differences between Cython and Swig and have implemented both techniques, but I am still not sure what route is the best route to take. Basically I have been working on a C++ library and I would like to expose those functions to Python. Cython seemed rather complicated and required me to write several .pyx files for every C++ class that I needed to expose whereas SWIG just did the work for me. I don't have a lot of experience with either one of these wrapping methods to date, but it seems that SWIG is a clear winner for wrapping my C++ code. So what is the controversy? Why would I spend hours writting .pyx files in Cython to wrap my C++ when I could just write one simple .i file in SWIG? Furthermore, I use CMake as my build tool and it was WAY easier to build SWIG with CMAKE than with Cython. I feel that I must be missing something because even big projects like OpenCV are not using SWIG and before I dedicate my project to SWIG, I want to find out why I would rather use Cython or nothing at all. Here is a summary:
My project:
C++ source code is primary
Python is a nice to have, just want a path of least resistance to expose the majority of my C++ code.
Writting wrapper code sucks because now I have two places to maintain an API--I just want one, the C++ code.
Any advice is greatly appreciated. Also, I was curious about xdress.org--seems like that project has died though.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
It seems like there are many options of parallelizing Python. I have seen these options below:
shared memory:
therading, multiprocessing, joblib, cython.parallel
distributed memory:
mpi4py, parallelpython (pp)
any CUDA, OpenCL options?
Does anyone have experiences in using these or other parallel libraries? How do they compare to each other? I am particularly interested in the use of python in computation-intensive applications in scientific computing field.
any CUDA, OpenCL options?
There is pyCUDA for CUDA anyway.
There is pyOpenCL also. (I'm less familiar with OpenCL, there may be others.)
There are pyCUDA and pyOpenCL tags here on SO.
pyCUDA and pyOpenCL are basically "wrappers" AFAIK, but it's unclear what exactly you're looking for -- your scope appears to be wide.
As far as I know, pyPar and/or pyMPI are the two most frequently used libraries for computation intensive applications in the scientific field.
pyPar tends to be easier to use, while pyMPI is more feature complete - so the first is used more frequently for less complex computations.
Iirc, they are just python wrappers for the relevant C libraries, making them the highest performing/most efficient ones to use.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I use Python api for OpenCV Library and it's great. I want to adapt the same technology to my own C++ library. Here is the source code:
https://github.com/Itseez/opencv/tree/master/modules/python/src2
As far as I know this is not SWIG, or Cython but a manual approach. Can someone please explain the architecture of the Python wrapping?
the python scripts in opencv\modules\python\src2 are used to generate the api
first hdr_parser.py is run on the opencv c++header files (just try to run it!), to collect the classes/functions(that's what the EXPORTS_W and CV_WRAP tags are for in the c++ headers),
then gen2.py is the 'backend', which generates the python wrappers.
the java / matlab bindings are done in the very same way (just different backends)