[issue39434] Add float __floordiv__ fast path

2020-01-23 Thread Dong-hee Na


Dong-hee Na  added the comment:

@mark.dickinson

I extract the common function.
Now maintainence cost is same as AS-IS.

optimization is still work :)

AS-IS: Mean +- std dev: 360 ns +- 19 ns
TO-BE: Mean +- std dev: 185 ns +- 8 ns

what do you think?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39434] Add float __floordiv__ fast path

2020-01-23 Thread Dong-hee Na


Dong-hee Na  added the comment:

> (e.g., because someone decides to "fix" the floor float division)

Okay, what if we create a common divmod function except for creating a tuple?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39434] Add float __floordiv__ fast path

2020-01-23 Thread Mark Dickinson


Mark Dickinson  added the comment:

So the risk here is that by adding the floordiv fast path, the division code is 
duplicated, and that increases the risk of accidentally losing the invariant 
that `a // b` is interchangeable with `divmod(a, b)[0]` (e.g., because someone 
decides to "fix" the floor float division). That and the usual increased 
maintenance cost of more code.

Whether the optimization is worth the cost, I'm not sure. My gut feeling is 
not, but others may have different views.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39434] Add float __floordiv__ fast path

2020-01-23 Thread Dong-hee Na


Dong-hee Na  added the comment:

And on the other side,

>>> 3.8 // 0.0
Traceback (most recent call last):
  File "", line 1, in 
ZeroDivisionError: float divmod()

I think that people expect 
ZeroDivisionError: float floor division by zero

not the current message.
I caught this optimization issue during I investigate about the error message.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39434] Add float __floordiv__ fast path

2020-01-23 Thread Dong-hee Na


Dong-hee Na  added the comment:

> Is this worth optimizing? Floating-point floor division is a comparatively 
> rare operation.

1. I don't want to say that this should always be optimized.
2. However, this operation is a relatively primitive python operation. I think 
this optimization is easy to bring and worth it.
3. Besides, the relatively unchanged logic, so the maintenance cost is not 
expected to be large

--
nosy: +vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39434] Add float __floordiv__ fast path

2020-01-23 Thread Mark Dickinson


Mark Dickinson  added the comment:

Is this worth optimising? Floating-point floor division is a comparatively rare 
operation.

--
nosy: +mark.dickinson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39434] Add float __floordiv__ fast path

2020-01-23 Thread Dong-hee Na


Change by Dong-hee Na :


--
keywords: +patch
pull_requests: +17533
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/18147

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39434] Add float __floordiv__ fast path

2020-01-23 Thread Dong-hee Na


Change by Dong-hee Na :


--
type:  -> performance

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39434] Add float __floordiv__ fast path

2020-01-23 Thread Dong-hee Na


New submission from Dong-hee Na :

./python.exe -m pyperf timeit "a = 3.5" "b = a // 2"
AS-IS: Mean +- std dev: 377 ns +- 4 ns
my patch: Mean +- std dev: 204 ns +- 2 ns

--
assignee: corona10
messages: 360559
nosy: corona10
priority: normal
severity: normal
status: open
title: Add float __floordiv__ fast path

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com