On Tue, Aug 26, 2014 at 3:12 PM, John Cremona <john.crem...@gmail.com> wrote: > Sounds like a reasonable plan if you (or someone) can be bothered to > sort out the chenges which will need to be made in code and doctests!
Even then, personally I don't like it. See below for a different suggestion that is less intrusive. > There will be places where we now have: for p in primes(10^8): > do_something_with(p) which will still work when primes() returns a > list, so will not result in doctest failures, but which should be > changed. This will be rather tedious. > > On the plus side, I make the point that all these are functions at the > top level which will be discovered by beginners for whom > > sage: primes(100) > <generator object primes at 0x7f9335465a50> > > will just confuse. Experts can know about and use the iterator forms > of the functions. We could certainly make it do this with little effort: sage: P = primes(100); P Prime numbers of less than 100 We could then have for x in P: ... be the usual iterator. One could also do: sage: P.list() [...] to get back a list. And one could do sage: len(P) to get the number of primes, without computing them. So... my counterproposal is to make primes return a cython class with a few methods. This breaks new code, and will be more new user friendly. > > John > > On 26 August 2014 14:00, Vincent Delecroix <20100.delecr...@gmail.com> 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) >> >> 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 sage-nt+unsubscr...@googlegroups.com. >> To post to this group, send an email to sage...@googlegroups.com. >> Visit this group at http://groups.google.com/group/sage-nt. >> For more options, visit https://groups.google.com/d/optout. > > -- > 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 sage-nt+unsubscr...@googlegroups.com. > To post to this group, send an email to sage...@googlegroups.com. > Visit this group at http://groups.google.com/group/sage-nt. > For more options, visit https://groups.google.com/d/optout. -- William Stein Professor of Mathematics University of Washington http://wstein.org wst...@uw.edu -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.