Skip main navigation

What is data persistence?

Persistence in computer science is defined as ‘the characteristic of state that outlives the process that created it'
a robot studying a book of text

How might data be stored without computers? You may have an address book which stores the details of your friends and family, indexed by the first letter of their surname.

Books in a library are organised into categories and then stored in alphabetical order based on the author’s name.

As you may already be aware, data also needs to be stored in the computing world. For this, you need the data to demonstrate persistence.

What is persistence?

Persistence in computer science is defined as ‘the characteristic of state that outlives the process that created it’. But what does this mean?

Take, for example, writing code to write data to external files for future use. The code which wrote these files has since stopped running, but the files that were created still exist — this is persistence.

The act of saving and loading files in applications is the most basic example of the concept, but there are other examples. Every time you listen to a piece of digital music, or view a digital photo, you are opening a file that has previously been created and saved.

Why is it important?

But why is persistence so important? With persistence the code can save important information to an external file. This could be something as trivial as a high score or as important as patient medical data.

Code can also be used to access the data in the file in the future. If persistence did not exist then the code would simply forget and reset each time it is used.

Many programming languages have methods and frameworks to save and retrieve data from files. In Python there are the basic file operations to read and write to files. But these can be developed to work with more complex data structures, just like the address book example above, offering a logical and efficient means to store and access data.

For example, you can store address book data in a file using a string, as demonstrated previously, or you could structure the data into a dictionary that uses the name of a person to retrieve their details.

This article is from the free online

Programming 103: Saving and Structuring Data

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education