I\'ve resolved this issue, but I\'m wondering why it was caused in the first place. I used BeautifulSoup to identify this span from a webpage:
span =
Probably because str(span.contents) is calling the __str__ function inside the object span.contents and returning a smaller representation. You can use the pympler to measure the memory consumption
str(span.contents)
__str__
span.contents