09.11.17 14:22, Raymond Hettinger пише:
Stylistically, all of these seem awkward and I think there is more to it than 
just the name. I'm not sure it is wise to pass complex inputs into a 
two-argument macro that makes an assignment and has a conditional refcount 
side-effect.  Even now, one of the above looks to me like it might not be 
correct.

If you have found an incorrect code, please open an issue and provide a patch. But recently you have rewrote the correct code (Py_SETREF was not involved) in more complicated way [1] and have rejected my patch that gets rid of the duplication of this complicated code [2]. Please don't "fix" the code that is not broken.

[1] https://bugs.python.org/issue26491
[2] https://bugs.python.org/issue31585

Probably, we're the wrong people to be talking about this.  The proposal is to 
make these macros part of the official API so that it starts to appear in 
source code everywhere.  The question isn't whether the above makes sense to 
you and me; instead, it is whether other people can make heads or tails out the 
above examples.   As a result of making the macros official, will the Python 
world have a net increase in complexity or decrease in complexity?

I afraid that these macros will be used in any case, even when they are not the part of an official C API, because they are handy. The main purpose of documenting them officially is documenting in what cases these macros are appropriate and make the code more reliable, and in what cases they are not enough and a more complex code should be used. This would be a lesson about correct replacing references. I didn't write this in the source comment because it was purposed for experienced Python core developers, and all usages under our control and passes a peer review.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to