Thomas Dybdahl Ahle added the comment:
Installing libffi-dev worked for me.
--
nosy: +thomasahle
___
Python tracker
<https://bugs.python.org/issue31652>
___
___
New submission from Thomas Dybdahl Ahle :
Given a generator `f()` we can use `random.sample(list(f()), 10)` to get a
uniform sample of the values generated.
This is fine, and fast, as long as `list(f())` easily fits in memory.
However, if it doesn't, one has to implement the reservoir sampling
Thomas Dybdahl Ahle added the comment:
Just wanted to add another use-case. In a project I'm working on, we are
building a lot of graphs using code like this:
```
nodes = [
Node('node-name1',
children=[...],
classifier=has_foo),
Node('node-name2',
children
Thomas Dybdahl Ahle added the comment:
I don't know if it's worth the overhead to implement a multiselect, given we
only expose a median function.
I've rewritten select2 to be intro, just falling back on sorting. This doesn't
appear to degrade the performance.
I also added np.median
Thomas Dybdahl Ahle added the comment:
I think minimize expected-case time is a good goal. If we wanted minimize
worst-case time we would have to use k-means rather than quickselect.
My trials on random data, where sort arguably has a disadvantage, suggests
sorting is about twice as fast
Thomas Dybdahl Ahle added the comment:
If you have a good, realistic test set, we can try testing quick-select vs
sorting. If it's still not good, I can also reimplement it in C.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org
New submission from Thomas Dybdahl Ahle:
The statistics module currently contains the following comment:
FIXME: investigate ways to calculate medians without sorting? Quickselect?
This is important, because users expect standard library functions to use state
of the art implementations
Thomas Dybdahl Ahle added the comment:
I have written some proof of concept code here [1], I would appreciate you
commenting on it, before I turn it into a patch, as I haven't contributed code
to Python before.
I have tried to write it as efficiently as possible, but it is of course
possible
Thomas Dybdahl Ahle lob...@gmail.com added the comment:
For anyone who finds this through google,
if you are finding the inverse mod a prime, you can use fermats little theorem:
pow(a, -1, mod) = pow(a, a-2, mod).
(You also need that mod doesn't divide a).
--
nosy: +Thomas.Dybdahl.Ahle
Thomas Dybdahl Ahle lob...@gmail.com added the comment:
Why not just add support to the set container?
As far as I know, it is a binary search tree, so supporting random picking in
O(logn) should be easy.
--
nosy: +Thomas.Dybdahl.Ahle
___
Python
Thomas Dybdahl Ahle added the comment:
which means no global namespace access
Does that mean that you cannot use len and range in a Thread?
--
nosy: +lobais
_
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1722344
Thomas Dybdahl Ahle added the comment:
The fix looks nice.
I'll just implement it locally in my app for python 2.4.
Thanks
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1731
Thomas Dybdahl Ahle added the comment:
I run this now in the beginning of my code. As far as I can see it works
fine.
if not hasattr(Thread, _Thread__bootstrap_inner):
class SafeThread (Thread):
def encaps(self):
try:
self._Thread__bootstrap_inner
13 matches
Mail list logo