David Hwu | 1 Oct 03:05 2014
Picon

External Package Best Practice

We are looking at using Cython as the main tech behind our website.  Currently our stack is large with many dependencies.
For example:  Website Core depends on Frameworks A, B, C, D, E, F, G.  Each Framework depends on A-1, A-2, A-3, D-1, D-2, D-3, etc. etc.
This can get fairly large quickly, especially when we have to adopt a new version of framework (ie. B-Prime).

Was looking for feedback how this can be best handled without becoming repeating cost..

There are strong advocates who see the beauty of Cython and static typing feature set to help us write better code (granted using a sledge hammer to address dynamic typing issues).
A purist approach to cythonize all the dependencies outlined earlier is not a feasible solution.

Speed not being the prevailing factor, I am wondering about how others have solved this issue.  Community shared stories mainly around speed and improving the ONLY critical parts of the code as the main Cython workflow and value.

Providing a moat/glue layer between dependent framework and core cythonized code is another possible solution I have used prior.  In this case the framework and their dependencies would be pure open source Python code.

Is there anything I might be missing here?
Thanks!
David


--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Yuxiang Wang | 30 Sep 21:39 2014
Picon

Anaconda configuration files?

Hi all,


I tried Anaconda3 (Windows, 64-bit, Python 3.4) earlier today and noticed that it bundles Cython really nice... I am able to use pyximport without specifying parameters. So, instead of

import pyximport 
pyximport.install(setup_args={"script_args":["--compiler=mingw32"], "include_dirs":numpy.get_include()})

I just ran 

import pyximport; pyximport.install()


For example, I used this simple cython code:

test_cy.pyx

import numpy as np

cpdef double [:] func():
    cdef double [:] a = np.arange(10.)
    return a

And then in IPython,

import pyximport; pyximport.install()
import test_cy
a = test_cy.func()
print(list(a))

It just worked.


My question is: how did they do that? Where did they put their configuration files to include np.get_include(), as well as --compiler=mingw32?

Thanks!

-Shawn

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Brian | 28 Sep 03:27 2014
Picon

Relatively simple function that mainly performs arithmetic is called many times - naive optimization using Cython by defining types causes slowdowns. How would I go about properly Cythonizing?

I wrote up my question earlier on the code review stackexchange, so I will link to it: http://codereview.stackexchange.com/questions/64040/relatively-simple-function-that-mainly-performs-arithmetic-is-called-many-times

Please do let me know if there is anything I can do to clarify the question, or any additional information you might require that would help in answering the question. Currently, the code in question takes up about...40% of my runtime. So, learning how to optimize it would be a very big deal for me!

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
stonebig34 | 27 Sep 16:18 2014
Picon

LLVM-3.5.0-win32.exe for windows

Hello,

Excuse me in advance if the question is stupid.

On windows, can cython 0.21 use llvm 3.5 instead of mingw32 ? Is there an how-to somewhere ?

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
stonebig34 | 27 Sep 08:05 2014
Picon

any progress on cython for windows 64 bit ?

Hi,

I don't see any change on https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows

Is it still a lost cause to get cython working on windows 64 with a gcc or llvm compiler ?

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sturla Molden | 27 Sep 03:20 2014
Picon

New Visual C++ compiler for Python 2.7

It seems Microsoft has created a compiler for building C extensions and
binary wheels for Python 2.7.

http://aka.ms/vcpython27

--

-- 

--- 
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

刘振海 | 26 Sep 16:07 2014
Picon

add c++ like type inferance to cython

Hi everyone,
here I want to share some thoughts about type inferance under cython.
c++ can do type inferance with 'auto' keyword, like
auto a=1 //a is int
auto b=1.0 //b is float
So it will be amazing that cython has such feature.
I noted that cython accept code patten like "cdef a=1",
for now this code defines the type of 'a' as pyobject instead of 
int. So why not take this code patten as type inferance patten?
let's have a look about this kind of type inferance:
cdef a=1 #int
cdef b=1.0 #float
cdef c=<double>1.0 #double
cdef d=func_return_int() #int
cdef e=[] #python list
cdef f=cdefclass() #cdefclass type
...
any thoughts?

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Navin Shajan | 26 Sep 15:21 2014
Picon

Cython calls a function with two arguments when there should be only one.

Hi,

I compiled the following code with Cython and got "CompileError: command '/usr/bin/clang' failed with exit status 1".

# distutils: language = c++
# distutils: sources = tes.cpp cimport cython from libcpp.string cimport string cdef extern from "/Users/navin/tes.h": cpdef int tes_test(int input) except + cpdef double a(double b): return b+1+tes_test(1)

//tes.h
int tes_test(int input);

I tried to compile the generated cpp file myself (using the command cython used in unixccompiler.py) and found that clang did have good reason to reject it:

/Users/navin/.ipython/cython/_cython_magic_5342a19687372bce99cddee073c34bb9.cpp:620:17: error: no
      matching function for call to 'tes_test'
    __pyx_t_1 = tes_test(1, 0);
                ^~~~~~~~
/Users/navin/tes.h:3:5: note: candidate function not viable: requires single argument 'input', but 2
      arguments were provided
int tes_test(int input);
    ^
1 error generated.

I feel like I am missing something obvious here. Why is cython calling tes_test(1, 0) when it should be calling tes_test(1)?  

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Matthew Honnibal | 25 Sep 17:16 2014
Picon

cymem: A small utility class for managing memory with Cython

Hi,

The Cython docs refer to a technique of tying memory addresses to Python objects, so that the garbage collector can be used to trigger a call to free. I've found it useful to extend this idiom slightly, and have a Python class that manages a collection of memory addresses. I've found the idiom quite valuable. Before I started doing this, I was always struggling with periodic memory leaks.

I doubt I'm the first person to think of this, and the implementation is quite trivial, but I've bundled it up as a release anyway (partly just to learn how to!). 

https://github.com/syllog1sm/cymem
https://syllog1sm.github.io/cymem/

One thing I was unsure about was the decision to use malloc/free or the Python memory macros, PyMem_Malloc, PyMem_Free, etc. I've gone with the Python macros, but does this mean that calls to Pool.alloc will require the GIL?

Matthew Honnibal

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Neal Hughes | 24 Sep 12:35 2014
Picon

Text editor for cython

Curious what people use to edit their cython files.

I use Vim, which does syntax highlighting for all *.pyx, *.pyd files no problems.

But autocompletion tools like jedi-vim, only work for python. I know Pycharm has limited cython support as well.

Thoughts?

Neal

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jelle Zijlstra | 24 Sep 01:31 2014
Picon

Nonlocal variables are not handled correctly

Cython does not seem to be able to deal with variables used in nested functions:

$ cython --version
Cython version 0.21
$ cat test.py
import cython

<at> cython.locals(x=cython.int)
def f(x):
    def g():
        return x ** 2
    return g()

print f(3)
$ cython test.py
warning: test.py:6:17: local variable 'x' referenced before assignment
$ gcc -m32 -fPIC -I/home/jelle/ans/venv/include/python2.7 -c test.c -o test.o
$ python
Python 2.7.2 (default, Jun 26 2014, 20:30:42)
[GCC 4.8.2] on linux3
Type "help", "copyright", "credits" or "license" for more information.
>>> import test
0
>>>
$ python test.py
9

Am I missing something?

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gmane