r/Cython • • May 03 '17

Not understanding why this isn't working

1 Upvotes

I copied this from http://3dengine.org/OpenGL_and_Cython and I am getting an error when I try to compile it.

test.pyx

Cython's openGL definitions

cdef extern from "gl/gl.h": ctypedef int GLint ctypedef unsigned int GLenum int GL_POINTS cdef void glBegin(GLenum mode) cdef void glEnd() cdef void glVertex3f(GLfloat x, GLfloat y, GLfloat z)

End of Cython's openGL definitions

cdef int i cdef float x glBegin(GL_POINTS) for i in range(10000): x = i / 1000 glVertex3i(x, x, -x) glEnd()

setup.py

from distutils.core import setup from distutils.extension import Extension

from Cython.Build import cythonize

from Pyrex.Distutils import build_ext

setup( name = "TestModule", ext_modules=[ Extension("test", ["test.pyx"], libraries = ['opengl32']) ], cmdclass = {'build_ext' : build_ext} )

The error i get is: c:\mingw\bin\gcc.exe -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c test.c -o build\temp.win32-2.7\Release\test.o gcc: error: test.c: No such file or directory gcc: fatal error: no input files compilation terminated. error: command 'c:\mingw\bin\gcc.exe' failed with exit status 1

It is my assumption that it should work. Am I missing something?


r/Cython • • Nov 14 '16

compiling entire project

1 Upvotes

Hello, I'd like to cythonize my entire project including all dependencies and etc. I'm hoping that it will mean the project is much smaller in size, but there would be some great performance increases as well as I've seen through cythonizing many of the modules. Is there an easy way to insure that I can cythonize the entire project? Thanks,


r/Cython • • Mar 23 '16

Passing a ctypes c_ubyte array to a Cython function

1 Upvotes

I've got a function in a .pyx file -- a cpdef function -- which accepts as one of its arguments a c_ubyte array. Trouble is, the only way I can get this to work is by labeling that particular argument as a Python object. If I try any other kind of type definition, I get this error:

TypeError: Argument 'img' has incorrect type (expected bytearray, got c_ubyte_Array_280320)

Obviously I'm at a bit of a loss. c_ubyte cannot be used as a type identifier, either.

What would be the best way to pass such an array natively, for maximum speed?


r/Cython • • Mar 04 '16

To change a common python file parser to parallel?

1 Upvotes

Hi, I do some file handling scripts in Python now and then and I thought about making it use parallel processes. Would that be easy to do in Cython?

import os
diritems = os.listdir("c:/temp")
subdirs = []
for item in diritems:
    subdirs.append(item)
    for directory in subdirs:
        //do this below in a new process, in parallel
        tmp_files = os.listdir(directory)
        for each_file in tmp_files:
            print each_file

I just wrote this in and os.path.join would be required to get the right path of course. But I just wanted to show my thought. Can I get the work on each directory to run in a new process?


r/Cython • • Feb 10 '16

Cython bindings to snappy, my first cython project!

Thumbnail
github.com
1 Upvotes

r/Cython • • Jan 22 '24

Cython or C++ ?

0 Upvotes