Re: on a very slow function

2017-10-02 Thread Daniel Bastos
Ben Bacarisse writes: > Daniel Bastos writes: > >> def make_sequence_non_recursive(N, x0 = 2, c = -1): >> "What's wrong with this function? It's very slow." >> last = x0 >> def sequence(): >> nonlocal last >>

Re: on a very slow function

2017-10-02 Thread Daniel Bastos
Chris Angelico writes: [...] > Maybe "linear_congruential" would be a good name for the function? I > don't know. Sounds good to me --- in absence of a smaller name. > Anyhow, the basic memoization technique should help you some. It did! Thanks so much to you and to everyone who contributed

Re: on a very slow function

2017-10-02 Thread Daniel Bastos
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Daniel Bastos writes: >> That function produces a function which yields the values of the >> sequence x^2 - 1 mod N > > Thats a term with two free variables. > I am not sure what the sequence is. > > And if that&

Re: on a very slow function

2017-10-01 Thread Daniel Bastos
Chris Angelico writes: > On Mon, Oct 2, 2017 at 8:27 AM, Daniel Bastos wrote: >> def make_sequence_non_recursive(N, x0 = 2, c = -1): >> "What's wrong with this function? It's very slow." >> last = x0 >> def sequence(): >> nonlo

on a very slow function

2017-10-01 Thread Daniel Bastos
def make_sequence_non_recursive(N, x0 = 2, c = -1): "What's wrong with this function? It's very slow." last = x0 def sequence(): nonlocal last next = last last = last**2 + c return next % N return sequence It crawls pretty soon. Please advise? Thank you. >>> f = make_se

Re: "Best" websocket implementation for Python 2.x?

2017-03-09 Thread Daniel Bastos
Skip Montanaro writes: [...] > These two packages would appear to have stalled. Looking around, I also > found > > ws4py > websockets - Python 3.3 or later > autobahn.websocket > > There are probably others I haven't yet stumbled upon. (I'd continue poking > around PyPI, but it seems the server