Re: Get["file.mx"] doesn't work
- To: mathgroup at smc.vnet.net
- Subject: [mg119054] Re: Get["file.mx"] doesn't work
- From: Peter Pein <petsie at dordos.net>
- Date: Fri, 20 May 2011 07:03:00 -0400 (EDT)
- References: <iqtnbm$io4$1@smc.vnet.net> <ir09p4$20l$1@smc.vnet.net> <ir2vr9$h50$1@smc.vnet.net>
Am 19.05.2011 13:44, schrieb Albert Retey: > Hi, > >> There is an interesting alternative to using MX files, which seems to >> be portable: >> >> str=OpenWrite[file,BinaryFormat->True]; >> BinaryWrite[str,Compress[expr],"TerminatedString"]; Close[str]; >> > > Another alternative seems to be WDX (Wolfram Data eXchange) which I am > using without problems on a variety of machines and which also seems to > be portable, can be used exactly like MX files, is binary, is documented > and thus I would consider officially supported. And it is used by the > data paclet functionality, so I guess it is reasonably performant and > well tested on all systems (an assumption which my experience does > support up to now). > > On the other hand that format seems to not be promoted by Wolfram very > much. Has anyone any information what the "official" state of that > format is, and whether WRI thinks it is save and recommended to be used > by ordinary users or not? > > Honestly I could well imagine that WDX basically does something very > close to what David suggested :-). If anyone has time to do some > performance comparison between the two, I would be interested to hear > the results... > > cheers, > > albert > > > soory to say, Albert, but Ex- and Import is not an easy to handle alternative to DumpSave: In[1]:= f[x_]:=x+1 In[2]:= SetDirectory["C:\\Users\\Peter"]; In[3]:= DumpSave["f.mx",f]; In[4]:= Remove[f]; In[5]:= <<"f.mx" In[6]:= f[a] Out[6]= 1+a this should work with an alternative. But: In[7]:= Export["f.wdx",f]; In[8]:= Remove@f In[9]:= Import["f.wdx"] Out[9]= f In[10]:= f[b] Out[10]= f[b] and of course the following leads to a real mess: In[11]:= f:=Import["f.wdx"] In[12]:= f[c] During evaluation of In[12]:= $RecursionLimit::reclim: Recursion depth of 256 exceeded. >> During evaluation of In[12]:= $RecursionLimit::reclim: Recursion depth of 256 exceeded. >> During evaluation of In[12]:= $RecursionLimit::reclim: Recursion depth of 256 exceeded. >> During evaluation of In[12]:= General::stop: Further output of $RecursionLimit::reclim will be suppressed during this calculation. >> Out[12]= $Aborted One would have to find a way to save all (d)ownvalues, upvalues (and possibly "inbetweenvalues" ;-) ) and to restore them. Not too trivial, is it? Cheers, Peter