Skip to content

Commit b1ec430

Browse files
committed
iplot performance improvement by 4x. Yikes.
Every _repr_* method that exists is called on instantiation of a IPython.core.display.HTML subclass. For Plotly, _repr_png, _repr_svg, _repr_jpeg require a call to the image server to generate the image. Combined, the 4 requests can make iplot commands take 4 times as long as usual. We mistakenly thought that the _repr_ commands were only called on demand, e.g. on a call to `nbconvert`. Unfortunately, this removes our support for `nbconvert`. An upcoming PR with cached images should bring this support back.
1 parent cbb2ee2 commit b1ec430

File tree

1 file changed

+0
-31
lines changed

1 file changed

+0
-31
lines changed

plotly/tools.py

-31
Original file line numberDiff line numberDiff line change
@@ -1230,34 +1230,3 @@ def __init__(self, url, width, height):
12301230

12311231
def _repr_html_(self):
12321232
return self.embed_code
1233-
1234-
def _repr_svg_(self):
1235-
url = self.resource + ".svg"
1236-
res = requests.get(url)
1237-
if six.PY3:
1238-
cont = res.content.decode('utf-8', 'replace')
1239-
else:
1240-
cont = res.content
1241-
return cont
1242-
1243-
def _repr_png_(self):
1244-
url = self.resource + ".png"
1245-
res = requests.get(url)
1246-
cont = res.content
1247-
return cont
1248-
1249-
def _repr_pdf_(self):
1250-
url = self.resource + ".pdf"
1251-
res = requests.get(url)
1252-
cont = res.content
1253-
if six.PY3:
1254-
cont = res.content.decode('utf-8', 'replace')
1255-
else:
1256-
cont = res.content
1257-
return cont
1258-
1259-
def _repr_jpeg_(self):
1260-
url = self.resource + ".jpeg"
1261-
res = requests.get(url)
1262-
cont = res.content
1263-
return cont

0 commit comments

Comments
 (0)