[issue31652] make install fails: no module _ctypes

2019-07-26 Thread Thomas Dybdahl Ahle
Thomas Dybdahl Ahle added the comment: Installing libffi-dev worked for me. -- nosy: +thomasahle ___ Python tracker <https://bugs.python.org/issue31652> ___ ___

[issue37682] random.sample should support iterators

2019-07-25 Thread Thomas Dybdahl Ahle
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

[issue33447] Asynchronous lambda syntax

2018-05-31 Thread Thomas Dybdahl Ahle
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

[issue21592] Make statistics.median run in linear time

2014-06-02 Thread Thomas Dybdahl Ahle
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

[issue21592] Make statistics.median run in linear time

2014-05-31 Thread Thomas Dybdahl Ahle
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

[issue21592] Make statistics.median run in linear time

2014-05-30 Thread Thomas Dybdahl Ahle
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

[issue21592] Make statistics.median run in linear time

2014-05-28 Thread Thomas Dybdahl Ahle
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

[issue21592] Make statistics.median run in linear time

2014-05-28 Thread Thomas Dybdahl Ahle
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

[issue457066] pow(a,b,c) should accept b0

2012-01-22 Thread Thomas Dybdahl Ahle
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

[issue7522] random.choice should accept a set as input

2010-05-06 Thread 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

[issue1722344] Thread shutdown exception in Thread.notify()

2008-02-06 Thread Thomas Dybdahl Ahle
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

[issue1731] Random errors on interpreter shutdown

2008-01-03 Thread Thomas Dybdahl Ahle
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

[issue1731] Random errors on interpreter shutdown

2008-01-03 Thread Thomas Dybdahl Ahle
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