Polyglot Notebooks: The difference between .dib and .ipynb Files

Polyglot Notebooks: The difference between .dib and .ipynb Files

Answering the most common question I get about Polyglot Notebooks

I’ve been talking more and more about Polyglot Notebooks and as people try it out, they tend to ask me one common question: should I create a .dib file or an .ipynb file? What’s the difference anyways?

Create as .dib or .ipynb

In this short article I’m going to explore the .dib and .ipynb file formats and explain the difference between the two while answering the question of which one you should choose when creating your own notebooks in Polyglot Notebooks.

.ipynb Files

.ipynb files are interactive python notebook files and are a format introduced by Jupyter Notebooks.

These files represent the code and markdown in a data science notebook plus the metadata behind the notebook’s execution, including the results of the last time each cell was run.

This means that an .ipynb file contains everything you need to read the notebook in the form it was last executed without needing to re-run the notebook.

However, you should also understand that .ipynb files are larger than .dib files and are not intended to be manually edited. This means that these files will take up more disk space and may be harder to manage in a version-controlled environment where you may encounter situations where you need to merge changes into the same notebook.

.dib Files

.dib files are a new file format introduced with Polyglot Notebooks. I’ve not seen a definition for the file extension, but if I had to guess I’d wager that it stood for dotnet interactive notebook.

Like .ipynb files, .dib files store the code and documentation present in a notebook. However, unlike an .ipynb file, the results of prior executions are not stored in a .dib file. This means that .dib files are much smaller and are easier to manage in a version-controlled environment.

Here’s a small snippet from a .dib file for reference:




### Classes

Note: Custom namespaces and `partial` classes are not supported. Classes exist in the global namespace.


public class Point
    public Point(int x, int y) {
        this.X = x;
        this.Y = y;

    public int X {get; set;}
    public int Y {get; set;}

    public override string ToString() => $"Point({X}, {Y})";


// Instantiate the class
Point p = new(4,2);


As you can tell, .dib files are shockingly simple and consist purely of the markdown and code mixed together with directives that govern the flow of cells.

Should you Choose .dib or .ipynb Files?

So now that we see that .ipynb and .dib files are relatively similar, but .dib files are smaller and don’t store results, you’ll need to make a decision as to which you should use for your projects.

My personal preference is to go with .dib files unless I have a compelling reason to go with .ipynb files instead.

For example, if I wanted to share a notebook file with someone else and not require them to execute its code, an .ipynb file would be a good choice.

Similarly, if I had a team of Python developers who are familiar with .ipynb files or a toolset geared around those files, I’d probably want to stick with that file format for simplicity.

However, barring any compelling reason to go with .ipynb files, I personally prefer the smaller .dib files that are easier to manage in version control and clearly communicate by their extension that the code I’m working with is a Polyglot Notebooks notebook.

So, as with anything in software, it depends, but hopefully this article has given you and your team enough information to make your choice when creating a new Polyglot Notebook.