#11763: merge with 3.1.
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index 01c5a7b..3f2f37d 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -263,6 +263,10 @@
 
     maxDiff = 80*8
 
+    # If a string is longer than _diffThreshold, use normal comparison instead
+    # of difflib.  See #11763.
+    _diffThreshold = 2**16
+
     # Attribute used by TestSuite for classSetUp
 
     _classSetupFailed = False
@@ -1048,6 +1052,10 @@
         self.assertIsInstance(second, str, 'Second argument is not a string')
 
         if first != second:
+            # don't use difflib if the strings are too long
+            if (len(first) > self._diffThreshold or
+                len(second) > self._diffThreshold):
+                self._baseAssertEqual(first, second, msg)
             firstlines = first.splitlines(True)
             secondlines = second.splitlines(True)
             if len(firstlines) == 1 and first.strip('\r\n') == first: