This thread is a mess. Move semantics is nothing more than creating a shallow 
copy that steals the inner state of a previous instance. It's an optimization, 
and moving out of a variable never makes the previous instance unusable:

    void f1(std::vector<int>&& vec);

    void f2() {
        std::vector<int> vec;
        f1(std::move(vec));
    
        vec.push_back(2); // This compiles just fine
    }

Since move semantics are a pass-by-value optimization, they can't exist in 
python where calling any kind of function simply shares bindings. In python no 
matter how hard you try you'll never run into the "hollow" instances that move 
semantics leave behind.

Some of the use-cases described in this thread are actually about borrow 
checking: making it possible to terminate the semantic lifetime of a variable 
by passing it to a function. Manually propagating lifetime restrictions through 
type annotations is definitely possible, and could be supported with a mypy 
plugin, but it will be very verbose, and without any kind of "constness" in the 
language the added safety will be pretty limited.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/XFLGRVBLGD7P2TLT6Z55QK6356676A5H/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to