#13764: CartesianProduct with generators -> silent wrong answer
---------------------------------+------------------------------------------
Reporter: vbraun | Owner: sage-combinat
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.6
Component: combinatorics | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Volker Braun | Merged in:
Dependencies: | Stopgaps:
---------------------------------+------------------------------------------
Comment (by ncohen):
> Isn't all the funky stuff part of the `*EnumeratedSet` framework that
the combinat people are working on? I don't want to replace the
`CartesianProduct` iterator with something that incurs significant
overhead.
Yeah, when we need significant overhead we know that we can always
delegate to combinat stuff `:-P`
Of course, we could *only* do that with the elements of the list which are
generators, and use sensible code otherwise. With warnings everywhere.
Actually, perhaps the best would be that :
There is an optional flag called cache_iterator or something, which is
set to False by default. When it is set to False, the function behaves
exactly like the one you wrote, that is REFUSES INPUT if there is an
iterator among them. The message could even say "if your iterators are all
finite, wrap them with a `list()` to make them finite.
Then, we could say (in the exception message, or in the doc, or at both
places) that if you want the code to work with infinite stuff, or when you
cannot ensure that all iterators are finite, and hence cannot wrap them
with `list()` casts, then you can set `cache_iterator` to `True` which
would do all the caching (or call the combinat stuff and enjoy their
overhead if they already wrote it somewhere).
Hence :
* No speed loss for smart cases
* The speed will not be destroyed because the user forgot to wrap with
`list()` calls, or just did not know it could make a difference
* Crazy guys iterating on infinite things can still use the function,
be it finally implemented in the method itself or delegated to combinat
stuff.
Well.. Is there any other corner case ? `:-P`
Nathann
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13764#comment:9>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.