davidhalter: I like! Thanks man. Good test.
diff --git a/AUTHORS.txt b/AUTHORS.txt
index b5619dcb..52204a8b 100644
--- a/AUTHORS.txt
+++ b/AUTHORS.txt
@@ -43,6 +43,7 @@ bstaint (@bstaint)
 Mathias Rav (@Mortal) <rav@cs.au.dk>
 Daniel Fiterman (@dfit99) <fitermandaniel2@gmail.com>
 Simon Ruggier (@sruggier)
+Élie Gouzien (@ElieGouzien)
 
 
 Note: (@user) means a github user name.
diff --git a/jedi/evaluate/compiled/mixed.py b/jedi/evaluate/compiled/mixed.py
index dfb49657..1390ea47 100644
--- a/jedi/evaluate/compiled/mixed.py
+++ b/jedi/evaluate/compiled/mixed.py
@@ -116,8 +116,21 @@ def _load_module(evaluator, path, python_object):
     return module
 
 
+def source_findable(python_object):
+    """Check if inspect.getfile has a chance to find the source."""
+    return (inspect.ismodule(python_object) or
+            inspect.isclass(python_object) or
+            inspect.ismethod(python_object) or
+            inspect.isfunction(python_object) or
+            inspect.istraceback(python_object) or
+            inspect.isframe(python_object) or
+            inspect.iscode(python_object))
+
+
 def find_syntax_node_name(evaluator, python_object):
     try:
+        if not source_findable(python_object):
+            raise TypeError  # Prevents computation of `repr` within inspect.
         path = inspect.getsourcefile(python_object)
     except TypeError:
         # The type might not be known (e.g. class_with_dict.__weakref__)

Slow completion for existing object with long `__repr__` method
Hi,

For completion with existing objects it seems that the `__repr__()` method is evaluated for an error message within the inspect module which is afterward caught. This makes the completion as slow as `__repr__()` while this evaluation in unnecessary for the user. This method can bee rather slow with big pandas objects or custom class.

This as been seen here :
[qtconsole issue #90](https://github.com/jupyter/qtconsole/issues/90)

A minimal code to reproduce it :
```python
import jedi
class Bugger(object):
    def __init__(self, size=10000):
        """Create bigg data."""
        self.big_data = [list(range(i)) for i in range(size)]

    def easy_method(self):
        """Method that should be really fast."""
        return self.big_data[-1][-1]

    def __repr__(self):
        output = ""
        for nested in self.big_data:
            for elem in nested:
                output += str(elem)
            output += '\n'
        return output

test = Bugger()
jedi.Interpreter('test.ea', [locals()]).completions()
```

And a more convenient working version :
```python
import jedi, pdb, inspect
class Bugger(object):
    def __init__(self, size=10):
        """Create bigg data."""
        self.big_data = [list(range(i)) for i in range(size)]

    def easy_method(self):
        """Method that should be really fast."""
        return self.big_data[-1][-1]

    def __repr__(self):
        frames = inspect.getouterframes(inspect.currentframe())
        for frame in frames:
            print(frame)
        pdb.set_trace()
        output = ""
        for nested in self.big_data:
            for elem in nested:
                output += str(elem)
            output += '\n'
        return output

test = Bugger()
jedi.Interpreter('test.ea', [locals()]).completions()
```

Jedi seems to end here through jedi/evaluate/compiled/mixed.py, line 121.
Maybe making checks before the calling `inspect.getsourcefile()` could fix it, but not I don't know jedi enough to claim it.
diff --git a/test/test_speed.py b/test/test_speed.py
index dcb69840..8d5bc9a3 100644
--- a/test/test_speed.py
+++ b/test/test_speed.py
@@ -51,3 +51,19 @@ class TestSpeed(TestCase):
         with open('speed/precedence.py') as f:
             line = len(f.read().splitlines())
         assert jedi.Script(line=line, path='speed/precedence.py').goto_definitions()
+
+    @_check_speed(0.1)
+    def test_no_repr_computation(self):
+        """
+        For Interpreter completion aquisition of sourcefile can trigger
+        unwanted computation of repr(). Exemple : big pandas data.
+        See issue #919.
+        """
+        class SlowRepr():
+            "class to test what happens if __repr__ is very slow."
+            def some_method(self):
+                pass
+            def __repr__(self):
+                time.sleep(0.2)
+        test = SlowRepr()
+        jedi.Interpreter('test.som', [locals()]).completions()

pip install -e .[dev]
parse_log_pytest
pytest
pytest
3.6
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs @ file:///opt/conda/conda-bld/attrs_1642510447205/work
certifi==2021.5.30
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1631916693255/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
-e git+https://github.com/davidhalter/jedi.git@c1c3f35e08a2404814d0463a648c562c15f1beb6#egg=jedi
more-itertools @ file:///tmp/build/80754af9/more-itertools_1637733554872/work
packaging @ file:///tmp/build/80754af9/packaging_1637314298585/work
pluggy @ file:///tmp/build/80754af9/pluggy_1615976315926/work
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pyparsing @ file:///tmp/build/80754af9/pyparsing_1635766073266/work
pytest==6.2.4
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
typing_extensions @ file:///opt/conda/conda-bld/typing_extensions_1647553014482/work
zipp @ file:///tmp/build/80754af9/zipp_1633618647012/work

name: jedi
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=21.4.0=pyhd3eb1b0_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - importlib-metadata=4.8.1=py36h06a4308_0
  - importlib_metadata=4.8.1=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - more-itertools=8.12.0=pyhd3eb1b0_0
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=21.3=pyhd3eb1b0_0
  - pip=21.2.2=py36h06a4308_0
  - pluggy=0.13.1=py36h06a4308_0
  - py=1.11.0=pyhd3eb1b0_0
  - pyparsing=3.0.4=pyhd3eb1b0_0
  - pytest=6.2.4=py36h06a4308_2
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - toml=0.10.2=pyhd3eb1b0_0
  - typing_extensions=4.1.1=pyh06a4308_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.6.0=pyhd3eb1b0_0
  - zlib=1.2.13=h5eee18b_1
prefix: /opt/conda/envs/jedi

test/test_speed.py::TestSpeed::test_no_repr_computation
test/test_speed.py::TestSpeed::test_os_path_join test/test_speed.py::TestSpeed::test_precedence_slowdown test/test_speed.py::TestSpeed::test_scipy_speed
AUTHORS.txt jedi/evaluate/compiled/mixed.py
AUTHORS.txt jedi/evaluate/compiled/mixed.py