Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generator-based exercises are rough #4

Open
parmentelat opened this issue Oct 21, 2019 · 2 comments
Open

generator-based exercises are rough #4

parmentelat opened this issue Oct 21, 2019 · 2 comments

Comments

@parmentelat
Copy link
Owner

release 0.6 comes with an experimental model for building generator-based exercises

we have 2 different and complementary mechanisms to limit / select output from the generator flow

  • max_iterations is set on the exercise instance; it acts more like an antiloop, and allows to limit the amount of iterations done no matter what
  • islice is set on the GeneratorArgs object and allows to select only a selection of the flow; designed to inspect for example the 1000-th iteration, within the same exercise and same actual parameters passed to the gen-func

within 0.6.0 these 2 mechanisms do not cohabit very nicely; when testing primes() with max_iterations=10_000 everything becomes super-slow
the point is that we need to call list() on the generator output rather early in the process - so that comparisons do the right thing - and it is very likely the point where things go wrong

@parmentelat
Copy link
Owner Author

parmentelat commented Oct 24, 2019

as a follow-up on this issue
release 0.6.1 was attempt to cope with iterators as arguments
issue being that such objects cannot be copied, but we need to copy Args instances so that all runs are isolated from one another

the path looked promising, but eventually I had to back down to 0.6.0 because the few generator-based exercises that I had written - and that I did not yet need this new feature - were not behaving properly, as somehow iterators tended to be used way further than needed

the initial intention was to create a differential exercise. it is still available but the copy_mode='tee' setting is no longer applied to all generator exercises by default, so it needs to be set explicitly so that argument iterators can be copied using itertools.tee()

@parmentelat
Copy link
Owner Author

one way to see the negative impact of 0.6.1 is to run the 'primes' exo from e.g. notebook #4 on generators
first example should stop at prime #20, but it goes on until 101 as per max_iterations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant