On Fri, Jun 11, 2021 at 10:12 AM Thomas Güttler <i...@thomas-guettler.de>
wrote:

>
>
> Am Fr., 11. Juni 2021 um 14:51 Uhr schrieb Ricky Teachey <
> ri...@teachey.org>:
>
>> I think this idea is promising but instead of doing it by adding new
>> syntax and a totally different object, why not attach a __templates__
>> dunder member to every string but only OPTIONALLY populate it when a string
>> is formatted?
>>
>>
> I am very happy that you think this is promising.
>
> Changing the interface of every string in Python feels much too big for
> me. I don't dare to think about it.
> I have concerns that it could have negative impacts on parts which I am
> not aware of.
>


I'm not a python internals expert, but i am imagining it wouldn't be a very
significant performance hog for anyone not interested in the feature...
seems like all that would be added is the equivalent of a __slot__ to the
str class object, and a reference to None inside it. so the memory
footprint of every string object would not have to grow. the class just
grows a new dunder.

the templated string objects themselves would have to have a bigger memory
footprint of course. but the user/developer is choosing to do that by using
templated strings.

---
Ricky.

"I've never met a Kentucky man who wasn't either thinking about going home
or actually going home." - Happy Chandler
_______________________________________________
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/OKIQ6SQHY7A7SLE4CMPSO7LM66BPUVVI/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to