Giter Site home page Giter Site logo

Comments (2)

smacke avatar smacke commented on May 22, 2024 1

Actually, I think this could be done in attrsub_tracer without too much difficulty. Whenever the obj_name parameter is non-null, then we can lookup the corresponding symbol in the tracer's current active scope and mark it as a dynamic usage. This is true regardless of whether the final object in the chain ends up being loaded, stored, or deleted. When obj_name is null, typically the actual obj is being returned from somewhere else and we don't need to worry about marking its corresponding symbol as dynamically used since that will happen at that same somewhere else.

We do, however, need to mark methods as used, and this might require some extra work since we can't just use obj_name for these.

from ipyflow.

smacke avatar smacke commented on May 22, 2024 1

cc @shreyashankar

Untested code for attrsub_tracer that might get us most of the way there:

if sym_for_obj is None and obj_name is not None:
    sym_for_obj = self.active_scope.lookup_data_symbol_by_name_this_indentation(obj_name)
if sym_for_obj is not None and sym_for_obj.defined_cell_num < nbs().cell_counter():
    sym_for_obj.version_by_used_timestamp[nbs().cell_counter()] = sym_for_obj.defined_cell_num

Can insert this snippet right below this line in attrsub_tracer.

This is untested though and there may be more to do there. For example, If we have

obj.foo()['bar']

I don't know whether it will correctly identify the usage of obj.foo (whose usage is not captured by the code snippet above; obj_name will be None since the object being subscripted is the thing that gets retuned from obj.foo(), not obj.foo).

Also it's worth testing on various aliasing scenarios.

from ipyflow.

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.