[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 sam

[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

[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 ad

[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

[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 <http://bugs.python.org/is

[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 pos

[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 implementa

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

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

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

2010-05-06 Thread Thomas Dybdahl Ahle
Thomas Dybdahl Ahle added the comment: I'm sorry. I see the problem then. Do you know, if there are any plans of adding a fast balanced binary search tree to pythons stdlib? -- ___ Python tracker <http://bugs.python.org/i

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

2010-05-06 Thread Thomas Dybdahl Ahle
Thomas Dybdahl Ahle 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 tracker <h

[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/

[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__boots

[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.pyt

[issue1731] Random errors on interpreter shutdown

2008-01-03 Thread Thomas Dybdahl Ahle
New submission from Thomas Dybdahl Ahle: I have a pygtk program, that uses a fairly lot of threads in a pool. All of these threads are setDaemon to ensure the application shuts down when I call gtk.main_quit() About every second time I close the app, I get one or more errors from places in the