Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7022087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:32:06+00:00 2026-05-27T23:32:06+00:00

Question: Is it possible to import an MX file saved using DumpSave without evaluating

  • 0

Question: Is it possible to import an MX file saved using DumpSave without evaluating the contents?


Let me illustrate:

Let’s create a variable, data:

In[2]:= data = Range[10]

Out[2]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

It can be exported to and imported from MX without making any definitions:

In[3]:= ImportString@ExportString[data, "MX"]

Out[3]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

But what if we use DumpSave?

In[4]:= DumpSave["data.mx", data]

Out[4]= {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}

(And clear data)

In[5]:= Clear[data]

On re-import, nothing is returned:

In[6]:= Import["data.mx", {"MX", "HeldExpression"}]

But the variable data becomes defined again, as if we had used Get.

In[7]:= data

Out[7]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

I would have expected to get something like Hold[data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}], i.e. something similar to what would be written to an .m file when using Save.


Perhaps it’s technically impossible to avoid the definition being made because DumpSave and Get directly manipulate the kernel state instead of writing and reading an evaluatable definition like Save does? This is just a guess.


(edit) please note: I am not trying to save in a way that can be imported “Held”. I can already do that using Export. I am looking to import previously DumpSaved MX files instead.


Answer It appears it is impossible to do this unless the MX file was saved to specifically allow it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:32:07+00:00Added an answer on May 27, 2026 at 11:32 pm

    My understanding is that the logic of .mx files is the inverse one: when you load an .mx file, the definitions (DownValues and others) for symbols are created at the lowest level, so that the values are assigned directly to the internal memory locations, by-passing the main evaluator. This is the reason why loading .mx files is so fast. It seems that you can’t have both – your expectation corresponds to a higher-level symbolic code. You can, however, encapsulate your data by using symbols in some context, as handles for that data.

    So, I don’t see a real problem here, since you can always query the DownValues and other ...Values of symbols and extract the r.h.sides of the rules in unevaluated form (there are some pathological cases for which DownValues don’t fully reconstruct the original definitions being stored in them, but they are, so to say, of measure zero, and not much practical importance). You can define certain interface, which would allow you to extract your data via a few functions (symbols), while the data can use many more symbols under the cover, which would be hidden behind those.

    EDIT

    If you control the initial use of DumpSave, here is an illustration of one possibility – you can create a custom dumpSave-like function. These are helper function to prepare information on symbols:

    ClearAll[dress];
    dress[prop_] := 
       Function[s, With[{pr = prop[s]}, Hold[prop[s] = pr]], HoldAll]
    
    ClearAll[getHeldProperties];
    getHeldProperties[HoldComplete[s_Symbol]] :=
     Thread[
        Through[(dress /@ {
            DownValues, UpValues, OwnValues,
            SubValues, DefaultValues, NValues, 
            FormatValues, Options, Messages, 
            Attributes
          })[Unevaluated[s]]], 
        Hold];
    

    for example:

    In[284]:= 
    getHeldProperties[HoldComplete[data]]
    
    Out[284]= Hold[{DownValues[data]={},UpValues[data]={},OwnValues[data]={HoldPattern[data]:>
    {1,2,3,4,5,6,7,8,9,10}},SubValues[data]={},DefaultValues[data]={},
    NValues[data]={},FormatValues[data]={},Options[data]={},Messages[data]={},
    Attributes[data]={}}]
    

    Now, the main function:

    ClearAll[dumpSave];
    SetAttributes[dumpSave, HoldRest];
    dumpSave[file_String, storage_Symbol, symbs___] :=
      Module[{n = 1},
        Replace[
          Thread[HoldComplete[{symbs}]],
          held : HoldComplete[s_] :> 
             (storage[n++] = getHeldProperties[held]), 
          {1}];
        DumpSave[file, storage]
    ]
    

    You basically designate a single symbol as a storage of unevaluated definitions of other symbols. Here is how you can use it:

    dumpSave["data.mx", storage, data, dumpSave, dress]
    

    If you now clear the storage symbol and load back the file, you will observe that all definitions of other saved symbols are stored in unevaluated form in DownValues of storage. You only need to call ReleaseHold on them to actually execute the assignments, but you also have access to them in unevaluated form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question: Is it possible to compile a program on linux using a .dll file?
Possible Duplicate: comparing contents of two files using python I have a file name
Until now it was possible to import data into an iPhone app using iTunes
Possible stupid question: let's say I have two apps contained within one project. Can
In Python 2.5 I stored data using this code: def GLWriter(file_name, string): import cPickle
I am currently using the Data Merge functions of ID CS4 to import some
Question: Is it possible to construct a web page that has a script to
Question: Is is possible, with regex, to match a word that contains the same
Question Is it possible to get the version of the Java Plugin being used
Question: Is it possible in back end code (not in the code behind but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.