Commit 68381bd9 authored by Jørgen Lien Sellæg's avatar Jørgen Lien Sellæg
Browse files

heavy test

parent 4bf58fa7
cmake_minimum_required(VERSION 2.8)
set(project_name pybind-example)
project(project_name)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wall -Wextra")
add_subdirectory("lib/pybind11")
pybind11_add_module("Prime" module.cpp)
pybind11 @ 9bb33131
Subproject commit 9bb3313162c0b856125e481ceece9d8faa567716
#include <pybind11/pybind11.h>
bool is_prime(int x) {
if(x < 2) {
return false;
}
for(int i = 2; i < x; ++i) {
if(x % i == 0) {
return false;
}
}
return true;
}
int next_prime(int x) {
while(!is_prime(x)) {
++x;
}
return x;
}
PYBIND11_MODULE(Prime, m) {
m.def("next_prime", &next_prime);
}
from sys import path
path.append("./heavy_example/var/build") # sorry
from Prime import next_prime
def is_prime(x):
if x < 2:
return False
i = 2
while i < x:
if x % i == 0:
return False
i += 1
return True
def py_next_prime(x):
while not is_prime(x):
x += 1
return x
def print_prime(prime):
print("Next prime is " + str(prime))
prime = 1000000000
# print_prime(py_next_prime(prime))
print_prime(next_prime(prime))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment