Hi, 2014-08-26 15:18 UTC+02:00, William A Stein <[email protected]>: > On Tue, Aug 26, 2014 at 3:00 PM, Vincent Delecroix > <[email protected]> wrote: >> Hello, >> >> Right now, we have the following functions >> - primes: an iterator over primes >> - prime_range: a list of primes (in Cython) >> - prime_powers: a list of prime powers >> - prime_power_range: another function that return a list of prime >> powers (in Cython from #16880) >> >> Given that >> - we can implement iterator in Cyhon >> - most function that end with 's' return lists (elliptic_curves, >> prime_divisors, quadratic_residues, ...) >> >> What do you think about: >> - move everything in Cython in `fast_arith.pyx` >> - having `primes` and `prime_powers` return lists >> - having `prime_iterator`and `prime_power_iterator` return iterators >> (with deprecation and everything) > > 1. Are you introducing a totally new convention? Does Python put > "_iterator" after function names to emphasize iterators? Do we do > that anywhere? In Python 3.x at least, they explicitly try not to > name iterators differently.
You are right. Even in Python 2.x. But how would you name two functions that does the same job but return in the first case an iterator and in the second a list? Note that adding "_range" after function names is not a Python convention either. > 2. Changing primes to return a list will break every explicit use of > primes I've ever used, in all my old code. For example, I might use > it like this (say): > > for p in primes(10^19,10^60): > if something(p): break > > If you change to a list, when I run the code my computer explode. I guess not only yours... so let me not change that. > 3. What motivates your suggested changes? I don't see a > sufficiently compelling argument for breaking tons of user code in > subtle ways yet. Sometimes that is worth doing.... but in 10 years, > I've heard no complaints before about the naming of the above > functions, so they probably aren't *horrible*. My main motivation comes from the fact that "primes" and "prime_powers" follow different conventions. It seems that not so much people care about "prime_powers" but I do. It would be better to make it consistent with primes. I am happy of keeping "primes" as an iterator, but if it stays I also want "prime_powers" being an iterator... Secondly, I am mostly interested in very small prime/prime powers (let say < 10000). And I am doing intensive iterations over them. In other words I need the code to be efficient in that range and the question is where I should perform this optimization. Best Vincent -- You received this message because you are subscribed to the Google Groups "sage-nt" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send an email to [email protected]. Visit this group at http://groups.google.com/group/sage-nt. For more options, visit https://groups.google.com/d/optout.
