DanielStutzbach / blist

A list-like type with better asymptotic performance and similar performance on small lists
Other
310 stars 36 forks source link

AttributeError when indexing ItemsView of a sorteddict #52

Closed matteodellamico closed 10 years ago

matteodellamico commented 10 years ago

In [11]: d = blist.sorteddict()

In [12]: d[1] = 2

In [13]: d.items() Out[13]: ItemsView(sorteddict({1: 2}))

In [14]: d.items()[0]

AttributeError Traceback (most recent call last)

in () ----> 1 d.items()[0] /usr/local/lib/python3.3/dist-packages/blist-1.3.4-py3.3-linux-x86_64.egg/_sorteddict.py in __getitem__(self, index) 30 return self._from_iterable((key, self._mapping[key]) 31 for key in keys) ---> 32 key = self._mapping.sortedkeys[index] 33 return (key, self._mapping[key]) 34 def index(self, item): AttributeError: 'sorteddict' object has no attribute 'sortedkeys' This bug is also signaled on stackoverflow: http://stackoverflow.com/questions/11285312/indexing-the-valuesview-of-a-sorteddict .
matteodellamico commented 10 years ago

This appears to be solved simply by replacing self._mapping.sortedkeys with self._mapping._sortedkeys in lines 32 and 53 of _sorteddict.py.

matteodellamico commented 10 years ago

I've seen that the problem is solved in the github repository; please update it on pypi. Thanks!

tallforasmurf commented 10 years ago

Yes please, as of 1 Mar 2014 the command "pip install -U blist" says I am up to date with version 1.3.4, however this bug is present. Thanks to Matteodellamico for the fix which I will install manually.

DanielStutzbach commented 10 years ago

I just uploaded blist 1.3.5 to PyPi with the fix.