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

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now