Jupyter messaging display_data vs execute_result

I am working with jupyter messaging and looking for some explanation about the difference between “display_data” and “execute_result”. The messaging doc states that the only difference is the execution counter, but that doesn’t seem to be a reason to use one over the other.

So my question is, why are there two messages that accomplish the same thing? Is there any reason to use one over the other?


As a quick note, the jupyter_client documentation should generally be considered the more maintained source of info.

A execute_request message can typically only result in a kernel returining one execute_result, and its status might be used by clients to do various things (such as not sending more requests).

Meanwhile, any number of display_data may be sent by the kernel, even after the execute_result, depending on the context, and typically will not be parsed by clients to determine if execution should continue (though they should be displayed… somewhere).