File tree Expand file tree Collapse file tree 6 files changed +10
-8
lines changed
source-code/cython/Pointers Expand file tree Collapse file tree 6 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 1+ pointers_cython.c
Original file line number Diff line number Diff line change 1- VERSION = cpython-34m
2- POINTERS_LIB = pointers .$(VERSION ) .so
1+ VERSION = cpython-311-x86_64-linux-gnu
2+ CYTHON_LIB = pointers_cython .$(VERSION ) .so
33
4- all : $(POINTERS_LIB )
4+ all : $(CYTHON_LIB )
55
6- $(POINTERS_LIB ) : pointers .pyx
6+ $(CYTHON_LIB ) : pointers_cython .pyx
77 python setup.py build_ext --inplace
88
99clean :
1010 python setup.py clean
11- rm -f pointers .c $(POINTERS_LIB )
11+ $( RM ) pointers_cython .c $(CYTHON_LIB )
Original file line number Diff line number Diff line change 22Simple example of using pointers in Cython code.
33
44## What is it?
5- 1 . ` pointers .pyx` : code that computes a list of squares using a cdef
5+ 1 . ` pointers_cython .pyx` : code that computes a list of squares using a cdef
66 function that increments an integer value referred to by a pointer.
771 . ` setup.py ` : Python build script.
881 . ` Makefile ` : make file to build the extension.
File renamed without changes.
Original file line number Diff line number Diff line change 44from Cython .Build import cythonize
55
66setup (
7- ext_modules = cythonize ('pointers.pyx' )
7+ ext_modules = cythonize ('pointers_cython.pyx' ,
8+ language_level = '3str' )
89)
Original file line number Diff line number Diff line change 11#!/usr/bin/env python
22
3- import pointers
3+ import pointers_cython as pointers
44
55
66print (pointers .squares (5 ))
You can’t perform that action at this time.
0 commit comments