Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #12789 > unrolled thread
| Started by | noomen mechri <noomenov@gmail.com> |
|---|---|
| First post | 2012-12-14 07:58 +0000 |
| Last post | 2012-12-18 07:35 +0000 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Mathematica 9 does not read mathematica 8 ".mx" files noomen mechri <noomenov@gmail.com> - 2012-12-14 07:58 +0000
Re: Mathematica 9 does not read mathematica 8 ".mx" files Michael Weyrauch <michael.weyrauch@gmx.de> - 2012-12-15 10:47 +0000
Re: Mathematica 9 does not read mathematica 8 ".mx" files David Bailey <dave@removedbailey.co.uk> - 2012-12-17 07:53 +0000
Re: Mathematica 9 does not read mathematica 8 ".mx" files John Fultz <jfultz@wolfram.com> - 2012-12-18 07:35 +0000
| From | noomen mechri <noomenov@gmail.com> |
|---|---|
| Date | 2012-12-14 07:58 +0000 |
| Subject | Re: Mathematica 9 does not read mathematica 8 ".mx" files |
| Message-ID | <kaem7o$5mu$1@smc.vnet.net> |
Thanks for your reply! yes, that's what I had to do ... rerun the whole calculation on M9 which again took a few hours!! (I know ... not good at optimizing code) But then what is the purpose of having .mx files to save the workspace variables for future use ... if they can only be read by the version in which they have been produced ... it is senseless ... On Tue, Dec 11, 2012 at 9:03 PM, Bob Hanlon <hanlonr357@gmail.com> wrote: > I've never used an .mx file; however, from the documentation: > > "MX files cannot be exchanged between different operating systems or > versions of Mathematica." > > "Mathematica MX files can be created with DumpSave and read with Get." > > Did you save the source files from which you did a DumpSave? If so, > move the source files to v9 and DumpSave new .mx files in v9. > > > Bob Hanlon > > > On Tue, Dec 11, 2012 at 2:24 AM, NBM <noomenov@gmail.com> wrote: > > Having written a lot of code on M8, I recently switched to M9 and tried > to > > run the code which starts by loading an .mx file written by M8, but M9 > wouldn't read it saying that it was written on another machine. This is a > major incompatibility issue between M8 and M9. Fortunately I kept my M8 > installation, so for now, M9 is useless to me. > > Please a solution. > > >
[toc] | [next] | [standalone]
| From | Michael Weyrauch <michael.weyrauch@gmx.de> |
|---|---|
| Date | 2012-12-15 10:47 +0000 |
| Message-ID | <kahkfl$d6l$1@smc.vnet.net> |
| In reply to | #12789 |
I am always surprised how quickly some people conclude a feature is "senseless". The .mx file is extremely useful if you need to dump a huge set of data to disk during a calculation and then reuse it later during this calculation. I need to use it all the time, and reading and writing is extremely fast. Unfortunately speed comes with non-portability, which is quite understandable. (By the way, much of Mathematica itself comes as .mx files, probably not so "senseless".) If you need portability, then use .wdx. It is portable, but not so fast to read. And all this is perfectly documented, and no big surprise. Michael Am 14.12.2012 08:58, schrieb noomen mechri: > Thanks for your reply! > yes, that's what I had to do ... rerun the whole calculation on M9 which > again took a few hours!! (I know ... not good at optimizing code) > But then what is the purpose of having .mx files to save the workspace > variables for future use ... if they can only be read by the version in > which they have been produced ... it is senseless ... > > > On Tue, Dec 11, 2012 at 9:03 PM, Bob Hanlon <hanlonr357@gmail.com> wrote: > >> I've never used an .mx file; however, from the documentation: >> >> "MX files cannot be exchanged between different operating systems or >> versions of Mathematica." >> >> "Mathematica MX files can be created with DumpSave and read with Get." >> >> Did you save the source files from which you did a DumpSave? If so, >> move the source files to v9 and DumpSave new .mx files in v9. >> >> >> Bob Hanlon >> >> >> On Tue, Dec 11, 2012 at 2:24 AM, NBM <noomenov@gmail.com> wrote: >>> Having written a lot of code on M8, I recently switched to M9 and tried >> to >>> run the code which starts by loading an .mx file written by M8, but M9 >> wouldn't read it saying that it was written on another machine. This is a >> major incompatibility issue between M8 and M9. Fortunately I kept my M8 >> installation, so for now, M9 is useless to me. >>> Please a solution. >>> >> >
[toc] | [prev] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2012-12-17 07:53 +0000 |
| Message-ID | <kamj1m$qqa$1@smc.vnet.net> |
| In reply to | #12789 |
On 14/12/2012 07:58, noomen mechri wrote:
> Thanks for your reply!
> yes, that's what I had to do ... rerun the whole calculation on M9 which
> again took a few hours!! (I know ... not good at optimizing code)
> But then what is the purpose of having .mx files to save the workspace
> variables for future use ... if they can only be read by the version in
> which they have been produced ... it is senseless ...
>
>
> On Tue, Dec 11, 2012 at 9:03 PM, Bob Hanlon<hanlonr357@gmail.com> wrote:
>
>> I've never used an .mx file; however, from the documentation:
>>
>> "MX files cannot be exchanged between different operating systems or
>> versions of Mathematica."
>>
>> "Mathematica MX files can be created with DumpSave and read with Get."
>>
>> Did you save the source files from which you did a DumpSave? If so,
>> move the source files to v9 and DumpSave new .mx files in v9.
>>
>>
>> Bob Hanlon
>>
>>
>> On Tue, Dec 11, 2012 at 2:24 AM, NBM<noomenov@gmail.com> wrote:
>>> Having written a lot of code on M8, I recently switched to M9 and tried
>> to
>>> run the code which starts by loading an .mx file written by M8, but M9
>> wouldn't read it saying that it was written on another machine. This is a
>> major incompatibility issue between M8 and M9. Fortunately I kept my M8
>> installation, so for now, M9 is useless to me.
>>> Please a solution.
>>>
>>
>
I hit the restriction with .mx files some time ago.
I really needed high speed, and I timed various alternatives. The best I
found, was to write the data:
str=OpenWrite[file,BinaryFormat->True];
BinaryWrite[str,magic,"TerminatedString"];
BinaryWrite[str,Compress[{expr,version}],"TerminatedString"];
Close[str];
(where magic is a short string to use as a sanity check when reading
back - omit if you prefer. expr is the large expression)
This can be read back with:
str=OpenRead[file,BinaryFormat->True];
If[BinaryRead[str,"TerminatedString"]==magic,
expr=Uncompress[BinaryRead[str,"TerminatedString"]];
];
Close[str];
The important point here, is that Compress and Uncompress are both fast
and portable.
This isn't quite as fast as .mx files, but close!
David Bailey
http://www.dbaileyconsultancy.co.uk
[toc] | [prev] | [next] | [standalone]
| From | John Fultz <jfultz@wolfram.com> |
|---|---|
| Date | 2012-12-18 07:35 +0000 |
| Message-ID | <kap6cl$46i$1@smc.vnet.net> |
| In reply to | #12789 |
On Dec 17, 2012, at 1:53 AM, David Bailey <dave@removedbailey.co.uk> wrote:
> On 14/12/2012 07:58, noomen mechri wrote:
>> Thanks for your reply!
>> yes, that's what I had to do ... rerun the whole calculation on M9 which
>> again took a few hours!! (I know ... not good at optimizing code)
>> But then what is the purpose of having .mx files to save the workspace
>> variables for future use ... if they can only be read by the version in
>> which they have been produced ... it is senseless ...
>>
>>
>> On Tue, Dec 11, 2012 at 9:03 PM, Bob Hanlon<hanlonr357@gmail.com> wrote:
>>
>>> I've never used an .mx file; however, from the documentation:
>>>
>>> "MX files cannot be exchanged between different operating systems or
>>> versions of Mathematica."
>>>
>>> "Mathematica MX files can be created with DumpSave and read with Get."
>>>
>>> Did you save the source files from which you did a DumpSave? If so,
>>> move the source files to v9 and DumpSave new .mx files in v9.
>>>
>>>
>>> Bob Hanlon
>>>
>>>
>>> On Tue, Dec 11, 2012 at 2:24 AM, NBM<noomenov@gmail.com> wrote:
>>>> Having written a lot of code on M8, I recently switched to M9 and tried
>>> to
>>>> run the code which starts by loading an .mx file written by M8, but M9
>>> wouldn't read it saying that it was written on another machine. This is a
>>> major incompatibility issue between M8 and M9. Fortunately I kept my M8
>>> installation, so for now, M9 is useless to me.
>>>> Please a solution.
>>>>
>>>
>>
> I hit the restriction with .mx files some time ago.
>
> I really needed high speed, and I timed various alternatives. The best I
> found, was to write the data:
>
> str=OpenWrite[file,BinaryFormat->True];
> BinaryWrite[str,magic,"TerminatedString"];
> BinaryWrite[str,Compress[{expr,version}],"TerminatedString"];
> Close[str];
>
> (where magic is a short string to use as a sanity check when reading
> back - omit if you prefer. expr is the large expression)
>
> This can be read back with:
>
> str=OpenRead[file,BinaryFormat->True];
> If[BinaryRead[str,"TerminatedString"]==magic,
> expr=Uncompress[BinaryRead[str,"TerminatedString"]];
> ];
> Close[str];
>
> The important point here, is that Compress and Uncompress are both fast
> and portable.
>
> This isn't quite as fast as .mx files, but close!
>
> David Bailey
> http://www.dbaileyconsultancy.co.uk
A bit of trivia here. One reason why Uncompress is fast is because, like .mx files, there is no need to parse the contents. Much of what makes .m files (and .nb files) slower than the alternatives is the lexing and parsing steps.
What you get after uncompressing a string created with Compress[] is a block of memory which already represents a Mathematica-style expression tree and all of the basic machine types. This expression tree doesn't, bit for bit, mirror the kernel in-memory representation like the .mx files do, but the transformations to get it there are straightforward and much faster than parsing the data would be.
The compression algorithm can slow things down too, of course, but you get some of that time back by reducing the amount of I/O required.
Sincerely,
John Fultz
jfultz@wolfram.com
User Interface Group
Wolfram Research, Inc.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web