This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Drop this in the Demos directory of Cython and run | |
# python setup.py build_ext --inplace && python -c 'import time_exc' | |
# cython: cdivision=True | |
# distutils: extra_compile_args = -O3 | |
import time | |
cdef int with_nothing(bint bad): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from libc.math cimport isnan as c_isnan | |
from math import isnan as math_isnan | |
from cmath import isnan as cmath_isnan | |
from numpy import isnan as numpy_isnan | |
cdef extern from "numpy/npy_math.h": | |
bint npy_isnan(double x) | |
def time_c_isnan(double value, long N=1000000): | |
cdef bint res = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fake_cythonize(patterns): | |
import glob, json, os | |
from distutils.extension import Extension | |
def is_package_dir(path): | |
return os.path.exists(os.path.join(path, '__init__.py')) | |
def package(filename): | |
dir = os.path.dirname(str(filename)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
import re | |
import sys | |
all = defaultdict(dict) | |
lineno = None | |
for line in sys.stdin: | |
m = re.match(r' */\* "(.*\.pyx)":(\d+)', line) | |
if m: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __BaseClass__ | |
#define __BaseClass__ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string> | |
using namespace std; | |
class BaseClass | |
{ | |
public: | |
BaseClass(){}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __BaseClass__ | |
#define __BaseClass__ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string> | |
using namespace std; | |
class BaseClass | |
{ | |
public: | |
BaseClass(){}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import cython | |
import numpy as np | |
@cython.boundscheck(False) | |
@cython.wraparound(False) | |
@cython.nonecheck(False) | |
@cython.cdivision(True) |
NewerOlder