Git Product home page Git Product logo

Comments (13)

pylint-bot avatar pylint-bot commented on July 22, 2024

Original comment by Buck Evan (BitBucket: bukzor, GitHub: @bukzor?):


Profile of analysis of a similar class with just 14 methods, which takes 30 seconds.

from astroid.

pylint-bot avatar pylint-bot commented on July 22, 2024

Original comment by Buck Evan (BitBucket: bukzor, GitHub: @bukzor?):


The raw data which was used to generate the above image.

from astroid.

pylint-bot avatar pylint-bot commented on July 22, 2024

Original comment by Buck Evan (BitBucket: bukzor, GitHub: @bukzor?):


The raw data which was used to generate the above image.

from astroid.

pylint-bot avatar pylint-bot commented on July 22, 2024

Original comment by Buck Evan (BitBucket: bukzor, GitHub: @bukzor?):


As a minor update, my attempt to time the inference on the somewhat smaller class is still running, ten days later. The cputime is 9 days, 20:58:43.

I'm killing it now.

from astroid.

pylint-bot avatar pylint-bot commented on July 22, 2024

Original comment by Sylvain Thénault (BitBucket: sthenault, GitHub: @sthenault?):


there is much probably an infinite loop somewhere which doesn't end into an
infinite recursion error and so ends endlessly.

from astroid.

pylint-bot avatar pylint-bot commented on July 22, 2024

Original comment by Buck Evan (BitBucket: bukzor, GitHub: @bukzor?):


My hypothesis is different: I believe it's tracing all the possible assignment paths in a permutative manner, yielding O(n^n) performance. With smaller numbers (3-10), it does complete, just exponentially slower for each new method.

from astroid.

pylint-bot avatar pylint-bot commented on July 22, 2024

Original comment by BitBucket: eevee, GitHub: @eevee?:


I looked into this a bit in the course of trying to improve pylint performance on a large and terrible codebase. :)

Buck is correct; this is equivalent to O(n^n). The following happens:

  • Encounter trans = self.transaction in method 1. Try to infer self.transaction.
  • Encounter self.transaction = trans in method 1. Infer trans. Find trans = self.transaction in method 1. Skip it because it's already being inferred.
  • Encounter self.transaction = trans in method 2. Infer trans. Find trans = self.transaction in method 2. Try to infer self.transaction.
  • Encounter self.transaction = trans in method 1...

This repeats rather ridiculously. Every assignment of self.transaction tries to infer from every assignment to it. Method 1 tries to infer from methods 2 through n, which each try to infer from methods 2 through n except themselves, etc. So each of n methods tries to infer from n - 1 methods which try to infer from n - 2 methods, and so on, producing O(n!). It only terminates at all because the inference of a particular expression is prevented from inferring itself; otherwise method 1 would try to infer itself forever.

I think I have a small fix for this, which involves extending the existing recursive-inference protection to avoid inferring the same attribute on an instance of the same class twice in the call stack. I'll post it as soon as I figure out how to do that with hg and bitbucket. :)

from astroid.

pylint-bot avatar pylint-bot commented on July 22, 2024

Original comment by Sylvain Thénault (BitBucket: sthenault, GitHub: @sthenault?):


sounds good eevee, thanks !

don't hesitate to ask for help for submitting your patch.

from astroid.

pylint-bot avatar pylint-bot commented on July 22, 2024

Original comment by Buck Evan (BitBucket: bukzor, GitHub: @bukzor?):


+1 +1

from astroid.

pylint-bot avatar pylint-bot commented on July 22, 2024

Original comment by Buck Evan (BitBucket: bukzor, GitHub: @bukzor?):


@eevee Put your diff on http://paste.pound-python.org/ if you're really stuck on bitbucket/hg.

This page always gives me enough information to do what I need with hg: http://mercurial.selenic.com/wiki/GitConcepts#Command_equivalence_table

from astroid.

pylint-bot avatar pylint-bot commented on July 22, 2024

Original comment by Sylvain Thénault (BitBucket: sthenault, GitHub: @sthenault?):


@eevee any update on this? Astroid should be released soon, it would be great if it could include a fix for this one.

from astroid.

pylint-bot avatar pylint-bot commented on July 22, 2024

Original comment by BitBucket: eevee, GitHub: @eevee?:


Finally submitted pull request #28, which includes a commit to fix this issue.

from astroid.

pylint-bot avatar pylint-bot commented on July 22, 2024

Original comment by Sylvain Thénault (BitBucket: sthenault, GitHub: @sthenault?):


Avoid recursively inferring the same attr on the same class. Closes #7

from astroid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.