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

Update of $OutputSizeLimit #581

Merged
merged 4 commits into from
Sep 27, 2016
Merged

Update of $OutputSizeLimit #581

merged 4 commits into from
Sep 27, 2016

Conversation

poke1024
Copy link
Contributor

This is a cleaned up, faster and better version of $OutputSizeLimit.

It now lives in its own class based on _MakeBoxesStrategy and makes the state more clean by using a dedicated class _LimitedMakeBoxesState. The whole code is now in expression.py to avoid the ugly in procedure imports needed for Expression until now.

There are two functional differences from the current code:

(1) The very first and the very last elements in a tree are now always output; e.g. Nest[Partition[#, 2]&, Range[2 ^7], 7] now yields {{{{{{{{1, <<1>>}, <<1>>}, <<1>>}, <<1>>}, <<1>>}, <<1>>}, {<<1>>, {<<1>>, {<<1>>, {<<1>>, {<<1>>, {<<1>>, 128}}}}}}}} (it yields a lame {<<1>>} with the current implementation).
(2) Every output that has been calculated using MakeBoxes is now always output and never thrown away.

(2) is a relaxation from the strict limit given by $OutputSizeLimit. The effect of this is a big speedup, since it no longer retries different parts of the expression to fit the remaining capacity, but simply outputs one and then stops. Try setting x=Nest[Partition[#, 2]&, Range[2 ^10], 10] and then outputting x several times; the current code is very sluggish (> 2s on my machine), this new code is fast (<.5 s).

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

Successfully merging this pull request may close these issues.

2 participants