Coder Social home page Coder Social logo

Comments (3)

tmadlener avatar tmadlener commented on July 17, 2024

Does this work on the c++ side? In principle it should as everything should live until the end of the statement. But in this case we create a temporary frame, from which we get a const & to a collection on which we then call size, so I am not entirely sure.

from podio.

jmcarcell avatar jmcarcell commented on July 17, 2024

Yes, on C++ there aren't any surprises and you can do everything in one line. But here frames[0] not being alive before the line ends seems unexpected.

from podio.

wlav avatar wlav commented on July 17, 2024

C++ and Python have different rules for temporaries: C++ guarantees that the lifetime of temporaries is at least until the end of the statement; in Python, temporaries go away whenever the reference count returns to zero, which may be in the middle of a long statement. If a C++ method returns something by reference to data that lives in a temporary object (that came to be from a different function call, say, in the long statement), then that data may go away before the end of life of the reference.

cppyy tries to set "lifelines" from such references onto the object that holds the data by checking whether the reference points to somewhere within the object on which the method was called. This automatic system would fail if the reference is to something that is not part of the temporary, but is still controlled by that temporary. E.g. if the reference points into data that is held by pointer by the object.

from podio.

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.