Message Boards Message Boards

0
|
2372 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Fastest way to write a very long expression to a file.

Posted 3 years ago

Hello everyone,

I was wondering what is the fastest way to write out a very long expression to a file in a human readable format, lets say InputForm with ASCII encoding. A suitable benchmark could be

expression = Plus @@ Table[1/n x^n, {n, 1, 2000000}];

or something with more terms. Using AbsoluteTiming, I see similar performance between Write and WriteString. Moreover, it looks like most of the time is spend converting the expression into a string

AbsoluteTiming[exprStr = ToString[expression, InputForm];]

Is this indeed the performance bottleneck, and if so, is there a way how the step can be speeded up?

POSTED BY: Tom Steudtner
2 Replies
Posted 3 years ago

Hi Tom,

Can you elaborate on why it has to be human readable? Is someone actually going to read an expression with 2 million terms?

POSTED BY: Rohit Namjoshi
Posted 3 years ago
POSTED BY: Tom Steudtner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract