[NumPy-Tickets] [NumPy] #2113: Python 3 dictionary view objects not supported
NumPy Trac
numpy-tickets@scipy....
Mon Apr 23 23:10:23 CDT 2012
#2113: Python 3 dictionary view objects not supported
------------------------+---------------------------------------------------
Reporter: khaeru | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: numpy.core | Version: 1.6.1
Keywords: |
------------------------+---------------------------------------------------
This seems to be related to #2019, except there is no segfault; just that
code that worked under Python 2.7 no longer works under 3.2.
{{{
import numpy
d = {0: numpy.zeros([5]), 1: numpy.ones([5])}
numpy.sum(d.values())
}}}
On Ubuntu, with the packages python2.7 2.7.3-0ubuntu3 and python-numpy
1:1.6.1-6ubuntu1, the result is:
{{{
5.0
}}}
With python3.2 3.2.3-0ubuntu1 and python3-numpy 1:1.6.1-6ubuntu1, the
result is:
{{{
dict_values([array([ 0., 0., 0., 0., 0.]), array([ 1., 1., 1., 1.,
1.])])
}}}
NumPy appears not to recognize the new Python 3
[http://docs.python.org/py3k/library/stdtypes.html#dictionary-view-objects
'dictionary view object']. In order to get the same result, I must do:
{{{
numpy.sum(list(d.values())
}}}
This gets very cluttered when feeding data from dicts to NumPy functions.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/2113>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list