Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This should work on ntfs filesystems, since they support <a href="http://en.wikipedia.org/wiki/Sparse_file" rel="noreferrer">sparse files</a>. It's almost instantaneous.</p> <pre><code>with open("file.to.create", "w") as file: file.truncate(10 ** 10) </code></pre> <p>The file will appearantly be filled with \x00 bytes, but those are in fact just created as needed when you read from the file. It uses almost no disk space (though it may <em>look</em> like it uses all 10 GB from the very beginning -- I've found no easy way to check the real file size in windows), and grows by allocating needed blocks when you write to it. AFAIK it's quite possible to create a sparse file that is much larger than the disk it resides on, though this may of course lead to trouble later on. :)</p> <p>Beware: if you copy a sparse file, it may in the process expand to a non-sparse file (read "fake" \x00 bytes, write <em>real</em> \x00 bytes). This is a consequence of the fact that it <em>looks</em> just like an ordinary 10 GB file with null bytes in order to be "backward compatible" -- separate checks must be performed to reveal it as a sparse file. To successfully copy a sparse file and keep it a sparse file, two conditions must be met:</p> <ul> <li>the tool used to copy it must be "aware" of sparse files, and </li> <li>the filesystem it is copied to must support sparse files</li> </ul> <p>For example, USB thumbdrives/pens are typically formatted with the old FAT filesystem by default, and it does <em>not</em> support sparse files. From testing, explorer of Windows XP appears not preserve sparse files when copying. <a href="http://www.tech-archive.net/Archive/Windows/microsoft.public.windows.file_system/2005-08/msg00152.html" rel="noreferrer">This tip</a> suggests <a href="http://en.wikipedia.org/wiki/Robocopy" rel="noreferrer">Robocopy</a> is up to the job, but I've not tested it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload