On 09/13/2018 07:01 AM, Eric V. Smith wrote: > On 9/12/2018 8:33 PM, Victor Stinner wrote: > >> Hi, >> >> For the type name, sometimes, we only get a type (not an instance), >> and we want to format its FQN. IMHO we need to provide ways to format >> the FQN of a type for *types* and for *instances*. Here is my >> proposal: >> >> * Add !t conversion to format string > > I'm strongly opposed to this. This !t conversion would not be widely > applicable enough to be generally useful, and would need to be exposed > in the f-string and str.format() documentation, even though 99% of > programmers would never need or see it. I discussed this with Eric in-person this morning at the core dev sprints. Eric's understanding is that this is motivated by the fact that Py_TYPE() returns a borrowed reference, and by switching to this !t conversion we could avoid using Py_TYPE() when formatting error messages. My quick thoughts on this: * If Py_TYPE() is a bad API, then it's a bad API and should be replaced. We should have a new version of Py_TYPE() that returns a strong reference. * If we're talking about formatting error messages, we're formatting an exception, which means we're already no longer in performance-sensitive code. So we should use the new API that returns a strong reference. The negligible speed hit of taking the extra reference will be irrelevant. Cheers, //arry/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180913/9958e926/attachment.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4