[Python-Dev] trunc() (original) (raw)

Russell E. Owen rowen at cesmail.net
Mon Jan 28 18:13:29 CET 2008


In article <79990c6b0801250553l2e6247adudf48112436dcda70 at mail.gmail.com>, "Paul Moore" <p.f.moore at gmail.com> wrote:

On 24/01/2008, Jeffrey Yasskin <jyasskin at gmail.com> wrote: > int has to be a builtin because it's a fundamental type. trunc() > followed round() into the builtins. I have no opinion on whether ceil > and floor should move there; it probably depends on how often they're > used.

Suggestion: - int() has to stay in builtins for obvious reasons. - put all of trunc, ceil, floor, round into math. - make int(float) an error

I like all of your suggestions except the last one. Remember the problem with a/b depending on whether b happened to be a float or an int? I think you'll be creating a very similar problem here. In my opinion int(foo) should do its best to turn foo into an int with predictable behavior.

The least surprising behavior for int(float) is probably trunc(float). Personally I prefer round(float), but I doubt it is worth breaking code and retraining everybody.

-- Russell



More information about the Python-Dev mailing list