[Python-Dev] cpython: fix compiler warning by implementing this more cleverly

Antoine Pitrou solipsis at pitrou.net
Wed Nov 23 01:46:15 CET 2011


On Tue, 22 Nov 2011 19:42:24 -0500
Benjamin Peterson <benjamin at python.org> wrote:
> 2011/11/22 Antoine Pitrou <solipsis at pitrou.net>:
> > On Tue, 22 Nov 2011 16:42:35 -0500
> > Benjamin Peterson <benjamin at python.org> wrote:
> >> 2011/11/22 Antoine Pitrou <solipsis at pitrou.net>:
> >> > On Tue, 22 Nov 2011 21:29:43 +0100
> >> > benjamin.peterson <python-checkins at python.org> wrote:
> >> >> http://hg.python.org/cpython/rev/77ab830930ae
> >> >> changeset:   73697:77ab830930ae
> >> >> user:        Benjamin Peterson <benjamin at python.org>
> >> >> date:        Tue Nov 22 15:29:32 2011 -0500
> >> >> summary:
> >> >>   fix compiler warning by implementing this more cleverly
> >> >
> >> > You mean "more obscurely"?
> >> > Obfuscating the original intent in order to disable a compiler warning
> >> > doesn't seem very wise to me.
> >>
> >> Well, I think it makes sense that the kind tells you how many bytes are in it.
> >
> > Yes, but "kind * 2 + 2" looks like a magical formula, while the
> > explicit switch let you check mentally that each estimate was indeed
> > correct.
> 
> I don't see how it's more magic than hardcoding 4, 6, and 10. Don't
> you have to mentally check that those are correct?

I don't know. Perhaps I'm saying that because I *have* already done
the mental check :)

Regards

Antoine.


More information about the Python-Dev mailing list