Daniil Pakhomov | 2 Jul 11:07 2015
Picon

Thread local variables in prange.

Hello.

I would be very glad if someone will help me to solve this problem.
I want to use thread-local variables in a prange loop.

Why it's not possible to use cython.parallel.threadlocal like it's mentioned here
https://github.com/cython/cython/wiki/enhancements-prange ?

Is this the only possible workaround by now:
https://groups.google.com/forum/#!topic/cython-users/Ady-DdWu6rE ?

Thank you.

--

---
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.
kloffy | 2 Jul 09:07 2015
Picon

libcpp - Any plans to add <memory> header?

Hi,

My understanding is that C++11 is still largely unsupported, but certain library features can already be implemented and would be *really* nice to have. I imagine smart pointers would be fairly high on the wishlist for many. Any plans for adding a memory header along the lines of the attached? (It contains some hacks and limitations, but it is mostly usable. Suggestions for improvement are welcome.)

Cheers,
kloffy

--

---
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.
Attachment (memory.pxd): application/octet-stream, 2520 bytes
Marcel Martin | 1 Jul 11:47 2015
Picon

Unable to deduce type parameters in global function

Hi,

I’m trying to wrap a heavily templatized C++ library that uses classes 
and global functions acting on them.

I would like to know why, in the following example, the last line gives 
me the error 'Unable to deduce type parameters' whereas I get no 
complaints about the line preceding it:

cdef extern from "file.h":
   cdef cppclass Container[T]:
     pass

   T get_first[T](Container[T])
   T get[T](Container[T], size_t)

cdef Container[int] c
get_first(c)
get(c, 1)

I’m just starting to use templates in Cython, so I wonder if I’m doing 
something wrong or whether this is just not supported.

Regards,
Marcel

--

-- 

--- 
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.

Marcel Martin | 1 Jul 11:28 2015
Picon

Compiler crash

Hi,

using 'cython --cplus' to cythonize the following code results in a 
compiler crash in Cython 0.22.1:

cdef extern from "...":
   cppclass Container[T]:
     Container()

   T get[T](Container[T])

cdef Container[int]* c = new Container()
get(c)

Regards,
Marcel

[...]
crash.pyx:8:3: Compiler crash in AnalyseExpressionsTransform

File 'Nodes.py', line 421, in analyse_expressions: 
StatListNode(crash.pyx:1:0)
File 'Nodes.py', line 4662, in analyse_expressions: 
ExprStatNode(crash.pyx:8:3)
File 'ExprNodes.py', line 434, in analyse_expressions: 
SimpleCallNode(crash.pyx:8:3,
     analysed = True,
     use_managed_ref = True)
File 'ExprNodes.py', line 4540, in analyse_types: 
SimpleCallNode(crash.pyx:8:3,
     analysed = True,
     use_managed_ref = True)
File 'ExprNodes.py', line 4593, in analyse_c_function_call: 
SimpleCallNode(crash.pyx:8:3,
     analysed = True,
     use_managed_ref = True)

Compiler crash traceback from this point on:
   File 
"/home/user/.local/lib/python3.4/site-packages/Cython/Compiler/ExprNodes.py", 
line 4593, in analyse_c_function_call
     entry = PyrexTypes.best_match(args, alternatives, self.pos, env)
   File 
"/home/user/.local/lib/python3.4/site-packages/Cython/Compiler/PyrexTypes.py", 
line 3963, in best_match
     [pattern.type.deduce_template_params(actual) for (pattern, actual) 
in zip(func_type.args, arg_types)],
   File 
"/home/user/.local/lib/python3.4/site-packages/Cython/Compiler/PyrexTypes.py", 
line 3963, in <listcomp>
     [pattern.type.deduce_template_params(actual) for (pattern, actual) 
in zip(func_type.args, arg_types)],
   File 
"/home/user/.local/lib/python3.4/site-packages/Cython/Compiler/PyrexTypes.py", 
line 3442, in deduce_template_params
     elif self.empty_declaration_code() == 
actual.template_type.empty_declaration_code():
AttributeError: 'CPtrType' object has no attribute 'template_type'

--

-- 

--- 
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.

Stefan Behnel | 1 Jul 08:52 2015
Picon

help needed to verify MSVC preprocessor check in memoryview code

Hi,

I stumbled over this code in MemoryView_C.c, line 36:

"""
#elif CYTHON_ATOMICS && MSC_VER
"""

Shouldn't this spell "defined(_MSV_VER)" ? Mind the leading underscore.

Could one of the MSVC users please verify with some memoryview code whether
this works or needs fixing? There is a macro "__PYX_DEBUG_ATOMICS" that you
can #define to make the C compiler issue a 'warning' for the code it uses
here, namely "Using MSVC atomics". Otherwise, you would see "Not using
atomics".

I considered simply changing it, but in the worst case, this might be code
that has never been used, so it might just break when enabling it. If both
versions work, I'd still like to change it because "_MSC_VER" is used
everywhere else and thus keeps the surprise level low.

Thanks!

Stefan

--

-- 

--- 
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.

Jerome Kieffer | 30 Jun 14:08 2015

Detect at runtime if OpenMP is possible ...

Dear Cythoners,

I try to write efficient code running everywhere ... using OpenMP
whenever possible. Often serial code is faster than parallel code on a
single core so I would like to select the path at _runtime_.

Do you think it would be possible/interesting to have the number of
threads available without linking to OpenMP ?

There is a reference to "threadsavailable" commented out a bit
everywhere in the source code of Cython. Could you tell me why it is
hidden ? there must be a reason.

Thanks in advance. Best regards

-- 
Jérôme Kieffer
tel +33 476 882 445

--

-- 

--- 
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.

Akash Sahu | 30 Jun 13:04 2015
Picon

Problem installing Cython-0.22.1 using python 2.7.10

Following are the libraries I have already installed

gcc - 4.8.1
python - 2.7.10
Mingw32

distutils.cfg value has the following
[build]
compiler = mingw32


I downloaded Cython-0.22.1, but while running python setup.py install I get the following error

building 'Cython.Plex.Scanners' extension
C:\MinGW\bin\gcc.exe -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c D:\Cython-0.22.1\Cython-0.22.1\Cython\Plex\Scanners.c -o d:\cython-0.22.1\cython-0.22.
1\cython\plex\scanners.o
D:\Cython-0.22.1\Cython-0.22.1\Cython\Plex\Scanners.c: In function '__Pyx_RaiseArgtupleInvalid':
D:\Cython-0.22.1\Cython-0.22.1\Cython\Plex\Scanners.c:6708:18: warning: unknown conversion type character 'z' in format [-Wformat=]
                  (num_expected == 1) ? "" : "s", num_found);
                  ^
D:\Cython-0.22.1\Cython-0.22.1\Cython\Plex\Scanners.c:6708:18: warning: format '%s' expects argument of type 'char *', but argument 5 has type 'Py_ssize_t' [-Wforma
t=]
D:\Cython-0.22.1\Cython-0.22.1\Cython\Plex\Scanners.c:6708:18: warning: unknown conversion type character 'z' in format [-Wformat=]
D:\Cython-0.22.1\Cython-0.22.1\Cython\Plex\Scanners.c:6708:18: warning: too many arguments for format [-Wformat-extra-args]
D:\Cython-0.22.1\Cython-0.22.1\Cython\Plex\Scanners.c: In function '__Pyx_RaiseTooManyValuesError':
D:\Cython-0.22.1\Cython-0.22.1\Cython\Plex\Scanners.c:6991:18: warning: unknown conversion type character 'z' in format [-Wformat=]
                  "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
                  ^
D:\Cython-0.22.1\Cython-0.22.1\Cython\Plex\Scanners.c:6991:18: warning: too many arguments for format [-Wformat-extra-args]
D:\Cython-0.22.1\Cython-0.22.1\Cython\Plex\Scanners.c: In function '__Pyx_RaiseNeedMoreValuesError':
D:\Cython-0.22.1\Cython-0.22.1\Cython\Plex\Scanners.c:6997:18: warning: unknown conversion type character 'z' in format [-Wformat=]
                  index, (index == 1) ? "" : "s");
                  ^
D:\Cython-0.22.1\Cython-0.22.1\Cython\Plex\Scanners.c:6997:18: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'Py_ssize_t' [-Wforma
t=]
D:\Cython-0.22.1\Cython-0.22.1\Cython\Plex\Scanners.c:6997:18: warning: too many arguments for format [-Wformat-extra-args]
writing d:\cython-0.22.1\cython-0.22.1\cython\plex\Scanners.def
C:\MinGW\bin\gcc.exe -shared -s d:\cython-0.22.1\cython-0.22.1\cython\plex\scanners.o d:\cython-0.22.1\cython-0.22.1\cython\plex\Scanners.def -LC:\Python27\libs -LC
:\Python27\PCbuild -lpython27 -lmsvcr90 -o build\lib.win32-2.7\Cython\Plex\Scanners.pyd
C:\Python27\libs/libpython27.a(dmmes01026.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:\Python27\libs/libpython27.a(dmmes00012.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:\Python27\libs/libpython27.a(dmmes00245.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:\Python27\libs/libpython27.a(dmmes00976.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:\Python27\libs/libpython27.a(dmmes01018.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:\Python27\libs/libpython27.a(dmmes00242.o):(.idata$7+0x0): more undefined references to `_head_C__build27_cpython_PCBuild_libpython27_a' follow
collect2.exe: error: ld returned 1 exit status
error: command 'C:\\MinGW\\bin\\gcc.exe' failed with exit status 1

any help will be highly appreciated.

--

---
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.
David Vierra | 29 Jun 14:09 2015
Picon

Proper way to initialize memoryview in stack-allocated struct?

I have defined a struct containing a memoryview. 

```
cdef struct MyStruct:
    unsigned int [:] my_mview
```

I allocate this struct on the stack as a local variable. 

```
cdef void MyFunction():
    cdef MyStruct local_struct
```

When assigning another object (a numpy array, to be precise) I get a C-level crash because my stack-allocated struct is not initialized. Unexpected - I should be able to overwrite an uninitialized struct however I want.

```
    local_struct.my_mview = numpy.arange(20)  /* ACCESS_VIOLATION */
```

The crash occurs inside the _PYX_XDEC_MEMVIEW, which does so reasonably as it is given an uninitialized __Pyx_memoryviewslice. I noted that when I declare a memoryview as a local variable, C code is generated that initializes the variable with something like `{ 0, 0, { 0 }, { 0 }, { 0 } }`, filling in the fields of the __Pyx_memoryviewslice. However, when I define my own struct containing a memoryview, and declare the struct as a local variable, no initialization code is generated for the struct's member.

What is the best way to initialize the struct as a local variable? I found I can write `local_struct.my_mview = None` (or even local_struct = [None, None, None] if it has several memoryviews in it), but would it be better to `memzero` the entire struct? Or do something else?

--

---
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.
Nathann Cohen | 28 Jun 18:34 2015
Picon

Compiling a Cython module *without* having the required libraries

Helloooooo everybody,

In Sage [1] we use Cython heavily, and several Cython modules are only
compiled if the necessary (optional) libraries are available locally.

As we generate our documentation from the Python modules using Sphinx
[2] (through Python introspection), it means that a large part of our
documentation is never built (because of the cython modules are not
compiled).

Would you happen to see a way to compile those Cython modules, even if
the shared libraries are not available? The functions could raise an
exception whenever called, but they would exist at Python level (and
have a documentation).

Thanks for your help,

Nathann

[1] http://www.sagemath.org/
[2] http://sphinx-doc.org/

--

-- 

--- 
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.

yoavg | 28 Jun 13:51 2015
Picon

wrapping c++11 code -- std::initalizer_list

Hello,

Is there support / syntax for wrapping C++11 functions that accept an std::initializer_list ?

concretely, let's assume I have a C++11 method with the following signature:

void Foo(std::initializer_list<float> x);

how would I call it from cython?

thanks

--

---
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.
Himanshu Mishra | 27 Jun 19:08 2015
Picon

Strange `filename.py` automatically being created while installing `filename.so`

Everything works great without installing, also it would work great even after installing, only if a strange file with the same name as of my .so file would not have been created each time I try installing. This new line has the following piece of code in it

def __bootstrap__():
   
global __bootstrap__, __loader__, __file__
   
import sys, pkg_resources, imp
   __file__
= pkg_resources.resource_filename(__name__,'filename.so')
   __loader__
= None; del __bootstrap__, __loader__
   imp
.load_dynamic(__name__,__file__)
__bootstrap__
()


So, if I try importing filename.so from it's location, this module filename.py is being imported each time. So, I can't use anything inside filename.so

Why is this file being created? Is there anyway I can avoid it?

Related : http://askubuntu.com/a/442363/424012

--

---
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