Toast the raw, shelled pistachios in a dry frying pan over a medium heat for about 5 minutes, stirring constantly until lightly golden and fragrant.
Remove the pistachios from the pan and leave to cool completely.
Transfer the cooled pistachios to a powerful food processor and blend on high speed, scraping down the sides occasionally, until you have a smooth, creamy paste (about 5–10 minutes).
Put a saucepan over a gentle heat and add the pistachio paste, icing sugar, whole milk, unsalted butter and a pinch of salt.
Whisk continuously for 5–7 minutes, until the mixture thickens slightly to the consistency of a thin custard. Avoid letting it come to a vigorous boil.
Remove the pan from the heat and stir in the vanilla extract, if using.
Pour the hot cream into a clean, dry glass jar and leave to cool completely at room temperature.
Once cooled, seal the jar and store in the fridge for 1–2 weeks. If it firms up too much, warm it briefly to restore its spreadable consistency.