Hi Shai,

If you used  '<{0} id="{1}"> {2} </{0}>'.format(tag, id, content) in a
templatetag (for example), it could easily be used iteratively which would
increase the need for performance and at that point, you could argue that
f'<{tag} id="{id}"> {content} </{tag}>' would be a preferable choice, even
though you are repeating the 'tag' argument.

More generally:

I understand the value of *not* doing a bulk change in a PR, but I was
wondering if it's OK to do a PR based purely on improved performance for a
specific element? (I don't have one in mind, the question is purely 'in
principle')

Thanks,

Dave


On Tue, 21 Jul 2020 at 12:08, Shai Berger <s...@platonix.com> wrote:

> On Tue, 21 Jul 2020 01:28:31 -0700 (PDT)
> Carlton Gibson <carlton.gib...@gmail.com> wrote:
> >
> > Certainly 99% of cases can be handled as cleanly (or more so, because
> > I guess we fell `format()` is a little verbose) with %-formatting or
> > an f-string.
> > But if we say format() is not allowed, don't we then guarantee we hit
> > the one case in X where "Actually, this version with format() is much
> > cleaner"?
> >
> FWIW, it seems to me one case where this happens is when you want to
> use one argument multiple times, without naming:
>
>         '<{0} id="{1}"> {2} </{0}>'.format(tag, id, content)
>
> Arguably, this specific example would look better with named references,
> but, IMO, not with % formatting:
>
>         '<%(tag)s id="%(id)s"> %(content)s </%(tag)s>' % dict(
>                 tag=tag,        id=id, content=content
>         )
>
> and as noted, f-strings have their limitations.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers  (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/20200721140822.47376bd8.shai%40platonix.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CADqmmRygoVynBgrYp1NwpJj3XTmeWFWNCVWP5zznCrstPXQd2A%40mail.gmail.com.

Reply via email to