#! /usr/bin/env python

from functools import lru_cache

import colormath as cm
import colormath.color_objects as co
import seaborn as sns

assert 949 == len(sns.xkcd_rgb)  # e.g. 'very light green': '#d1ffbd'


@lru_cache()
def get_name_to_srgb():
    keys = sns.xkcd_rgb.keys()
    return dict(zip(keys, sns.xkcd_palette(keys)))

def red_check():
    red = get_name_to_srgb()['bright red']
    red = co.sRGBColor(*red)
    assert not red.is_upscaled
    assert '#ff000d' == red.get_rgb_hex() == sns.xkcd_rgb['bright red']


if __name__ == '__main__':
    red_check()

@@ -70,14 +70,25 @@
 math
+.color_diff
  as c
-m
+d
 %0Aimp
@@ -121,16 +121,57 @@
 s as co%0A
+import colormath.color_conversions as cv%0A
 import s
@@ -377,20 +377,22 @@
 eys)))%0A%0A
+%0A
 def 
+_
 red_chec
@@ -573,16 +573,387 @@
 red'%5D%0A%0A%0A
+@lru_cache()%0Adef get_color_by_name(name):%0A    return co.sRGBColor(*get_name_to_srgb()%5Bname%5D)%0A%0A%0Adef distance_between_colors(c1: co.sRGBColor,%0A                            c2: co.sRGBColor):%0A    c1.rgb_r  # pass in some proper colors, please%0A    return cd.delta_e_cie2000(cv.convert_color(c1, co.LabColor),%0A                              cv.convert_color(c2, co.LabColor))%0A%0A%0A
 if __nam
@@ -975,16 +975,17 @@
 _':%0A    
+_
 red_chec
@@ -988,8 +988,219 @@
 check()%0A
+%0A    red = get_color_by_name('bright red')%0A    for name in 'bright red,red,pink,purple,violet,blue'.split(','):%0A        d = distance_between_colors(red, get_color_by_name(name))%0A        print(round(d, 1), name)%0A

Add distance_between_colors