t they might be useful parts of an efficient solution.
More information:
http://pypi.python.org/pypi/blist
http://stutzbachenterprises.com/blist/
--
Daniel Stutzbach
--
http://mail.python.org/mailman/listinfo/python-list
different performance characteristics, and a
sorteddict works just like a dict but keeps the keys sorted.
--
Daniel Stutzbach
--
http://mail.python.org/mailman/listinfo/python-list
d into Python source code?
>
Seems unlikely.
--
Daniel Stutzbach
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Jul 21, 2010 at 9:47 AM, Daniel Stutzbach <
dan...@stutzbachenterprises.com> wrote:
> What's new?
> ---
>
> - blist.sort() is now *substantially* faster than list.sort() when using
> int or float keys (O(n) vs. O(n log n))
> - The sortedset, sortedli
Thank you for the thoughts. I appreciate them!
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
at's a good point. It's tempting to add an undocumented parameter to
blist.sort that selects the sorting algorithm to use, to make it make it
easier to test multiple algorithms. There are probably several different
ways to achieve a similar effect. Do you mind if we table that discussion
unt
and resorts, list.sort will skip the sorted part,
> sort the additions, and merge them back in. Radix sort ignores pre-existing
> order. So either a lot of comparitive profiling would be needed for
> auto-selection of sort method, or it should be user selectable.
>
I'v
that I need to take
care of. After that I plan to work on porting my sort optimizations back to
the standard list type.
Here's a performance comparison of sorting with blist versus 3.1's list:
http://stutzbachenterprises.com/performance-blist/sort-random-list
--
Daniel Stutzbach, Ph.D.
Pres
mentation: http://stutzbachenterprises.com/blist/
- Download: http://pypi.python.org/pypi/blist/
- Source repository: http://github.com/DanielStutzbach/blist
- Issue tracker: http://github.com/DanielStutzbach/blist/issues
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzb
zbach/winreg_unicode/issues
Source code: http://github.com/DanielStutzbach/winreg_unicode
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
t is
ordered, we may be able to help you come up with a clever way to remove an
item cheaply.
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
;: -1})
>>> c = Counter({'red': 1})
>>> c2 = Counter({'red': 2})
>>> c - c2
Counter()
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Mar 2, 2010 at 1:58 PM, Martin P. Hellwig <
martin.hell...@dcuktec.org> wrote:
> What actually happens if multiple threads at the same time, write to a
> shared dictionary (Not using the same key)?
>
All of Python's built-in types are thread safe. Both updates wi
> matters.
>
Order and repetitions matter:
list1 == list2
Repetition matters, order does not:
sorted(list1) == sorted(list2) # items must be comparable
Neither matters:
set(list1) == set(list2) # items must be hashable
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://s
27;, 6: 'b', -5: 'c'})
>>> my_dict.keys()
[-5, 1, 6]
>>> my_dict[2] = 'd'
>>> my_dict.keys()
[-5, 1, 2, 6]
It's available here:
http://pypi.python.org/pypi/blist/
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
d only O(log n) time to trim l1.
You'd use it something like this:
>>> from blist import blist
>>> l1 = blist()
>>> # Here, populate l1 as you normally would
>>> l2 = l1[10:]
>>> del l1[10:]
It's available at: http://pypi.python.org/pypi/bli
ge collector.
>
A concurrent garbage collector for frozen object would still need to walk
unfrozen objects, to find references to frozen objects.
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Feb 10, 2010 at 5:23 PM, Peng Yu wrote:
> I'm wondering there is already a function in python library that can
> merge intervals.
>
Not in the standard library, but this package may help:
http://pypi.python.org/pypi/interval
--
Daniel Stutzbach, Ph.D.
President, Stutzba
If they're both long, I factor out one or both of the blocks
into functions.
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com/>
--
http://mail.python.org/mailman/listinfo/python-list
le(x) # y is a btuple with > 500 million elements
Feedback
We're eager to hear about your experiences with the blist. You can
email me at dan...@stutzbachenterprises.com. Alternately, bug reports
and feature requests may be reported on our bug tracker at:
http://github.com/DanielStutzbach/blist/issues
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com/>
--
http://mail.python.org/mailman/listinfo/python-list
a number between 1 and your sum without generating each and every
one.
choice = random.randrange(1, sum(i[0] for i in myList)+1)
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
1
return part_product(n, k) * part_product(k+2, m)
def n_minus_num_of_bits(v):
w = v
if w >= 2**32-1:
raise OverflowError
w -= (0x & w) >> 1
w = (w & 0x3333) + ((w >> 2) & 0x)
w = w + (w >> 4) & 0x0f0f0f0f
w += w >&g
bound to have different opinions about which operations
are most important and where lies the best tradeoff between different
operations (as well as code complexity). I am not sure why you feel so
strongly that particular spot is best.
Obviously, I prefer a slightly different spot, but I also respect t
exist as a third-party module.
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC
--
http://mail.python.org/mailman/listinfo/python-list
on with the built-in list here:
http://stutzbachenterprises.com/performance-blist
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Jan 21, 2010 at 12:45 PM, Jan Kaliszewski wrote:
> Please note that I used funcions from bisect, that use binary search.
>
> Doesn't it take O(log n) time?
>
It takes O(log n) time to find the point to insert, but O(n) time to perform
the actual insertion.
--
Danie
sort.
>
Indeed. In fact, blist 1.1 (to be released within a month or so) will
include sorteddict, sortedset, sortedlist, weaksortedset, and weaksortedlist
types.
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org
s(seq[i])
Alternately, if I'm using the blist extension type that I wrote, then
seq[1:] is O(log n).
http://pypi.python.org/pypi/blist/
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Dec 16, 2009 at 7:33 AM, Peter Otten <__pete...@web.de> wrote:
> islice() could be changed to special-case lists and tuples, but that feels
> a
> bit unclean.
>
How about special-casing objects that implement collections.Sequence?
--
Daniel Stutzbach, Ph.D.
Pr
ibute#distribute-setup-py
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
tting there in
t.join() with no exception handler around it.
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
ce, though. That takes O(n) time if you're
taking a big slice.
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
it -s 'from blist import blist'
'small_list=blist([0])' ''BIG_list=small_list*2**29'
'BIG_slice=BIG_list[4:-5]'
1 loops, best of 3: 21.5 usec per loop
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
es in debug builds
- Ported tests to run under Python 2.6 and Python 3.1 (but no longer Python
2.5)
- Got rid of warnings on non-ix86 platforms
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
_median
if my_median < value:
my_median += step_size
else:
my_median -= step_size
Let me know if you have any questions about it.
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
[1, 2, 3, 4, 5, 6]
i = 0
while i < len(a):
x = a[i]
if x == 3:
a.pop(i)
i += 1
continue
if x == 4:
a.append(88)
print "i", i, "x", x
i += 1
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
iour.
>
super() does not have the behavior that I would have expected, either, and
IMO the documentation is unenlightening.
I found the following website helpful in understanding what super()
*actually* does (though I do not support the author's hyperbolic
criticisms):
http://fuhm.net/sup
On Thu, Sep 24, 2009 at 2:51 PM, Ethan Furman wrote:
> I believe that modules are imported only once
>
That's *mostly* true, but try this one:
A.py:
print 'Importing A'
import B
B.py:
print 'Importing B'
import A
Cashew:/tmp$ python2.5 B.py
Importing B
Imp
n to that problem.
>>> items = ["a", "b", "c", "d"]
> >>> delenda = set([0, 3])
> >>> items = [item for index, item in enumerate(items) if index not in
> delenda]
> >>> items
> ['b', 'c']
wanted to keep.
>
You're absolutely right. My apologies. I need to learn not to post to
mailing lists first thing in the morning! ;-)
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
. Observe:
Python 2.6.2 (r262:71600, Apr 15 2009, 07:20:39)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> with open('/dev/null'
hs back:
http://mail.python.org/pipermail/python-ideas/2009-July/005114.html
<http://mail.python.org/pipermail/python-ideas/2009-July/005114.html%20>
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
r cumulative distribution functions require math
functions not currently provided by Python (erf, gamma, etc.).
(http://bugs.python.org/issue3366 includes a patch to provide them)
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.
), you can use the blist extension type from
http://pypi.python.org/pypi/blist/
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
tic performance
characteristics.
Copying a blist is O(1), so the functional-programming types can wrap it in
non-mutating semantics if they so choose. ;)
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
e called the "blist"
that has the same methods as a Python list, but has better asymptotic
performance for many operations. That way I can write use the list in the
most natural way without having to worry about accidentally hitting a O(n)
method.
http://pypi.python.org/pypi/blist/
--
lways outweighed the cost of later translating some of the code.
Hope that helps,
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
--
http://mail.python.org/mailman/listinfo/python-list
47 matches
Mail list logo