[issue26342] Faster bit ops for single-digit positive longs

2016-12-16 Thread Yury Selivanov

Yury Selivanov added the comment:

Closing this one, as we decided to not to micro-optimize int ops.

--
resolution:  -> wont fix
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue26342] Faster bit ops for single-digit positive longs

2016-02-12 Thread Yury Selivanov

Yury Selivanov added the comment:

> You should add a tests. especially for edge cases, for negative values for 
> example.

There are many binop tests in test_long.py

--

___
Python tracker 

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



[issue26342] Faster bit ops for single-digit positive longs

2016-02-12 Thread Марк Коренберг

Марк Коренберг added the comment:

You should add a tests. especially for edge cases, for negative values for 
example.

--
nosy: +mmarkk

___
Python tracker 

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



[issue26342] Faster bit ops for single-digit positive longs

2016-02-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Does this patch have effect with results over 8 bits? Does it have effect after 
applying patches from 24165?

--

___
Python tracker 

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



[issue26342] Faster bit ops for single-digit positive longs

2016-02-12 Thread Yury Selivanov

Yury Selivanov added the comment:

> Does this patch have effect with results over 8 bits? 

-m timeit -s "x=2**40" "x&2;x&2;x&2;x&333;x&3;x&3;x&;x&4"
with patch: 0.404usec  without patch: 0.41


> Does it have effect after applying patches from 24165?

I'm not sure how it's related, but let's modify the test to stress the mem 
allocation:

-m timeit -s "x=21827623" 
"(x+x)&2;(x+x)&2;(x+x)&2;(x+x)&333;(x+x)&3;x&3;(x+x)&;(x+x)&4"

this patch+freelist: 0.337usec   only freelist: 0.496

In any case, bit operations are often used for bit-flags logic, where numbers 
are usually aren't too big (it's rare to see more than 30 bit flags on one 
field).

--

___
Python tracker 

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



[issue26342] Faster bit ops for single-digit positive longs

2016-02-12 Thread Yury Selivanov

Yury Selivanov added the comment:

> with patch: 0.404usec  without patch: 0.41

Sorry, I made a typo: these results should be flipped -- 0.41-0.404 is the 
overhead of the fastpath's 'if' check.  I'd say it's a pretty small overhead -- 
we already optimize all other long ops, including bit inversion.

--

___
Python tracker 

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



[issue26342] Faster bit ops for single-digit positive longs

2016-02-11 Thread Yury Selivanov

New submission from Yury Selivanov:

This patch implements a fast path for &, |, and ^ bit operations for 
single-digit positive longs.  We already have fast paths for ~, and pretty much 
every other long op.


-m timeit -s "x=21827623" "x&2;x&2;x&2;x&333;x&3;x&3;x&;x&4"
with patch: 0.181  without patch: 0.403


-m timeit -s "x=21827623" "x|21222;x|23;x|2;x|333;x|3;x|3;x|;x|4"
with patch: 0.241  without patch: 0.342


-m timeit -s "x=21827623" "x^21222;x^23;x^2;x^333;x^3;x^3;x^;x^4"
with patch: 0.241  without patch: 0.332

--
assignee: yselivanov
components: Interpreter Core
files: fast_bits.patch
keywords: patch
messages: 260126
nosy: haypo, mark.dickinson, serhiy.storchaka, yselivanov
priority: normal
severity: normal
stage: patch review
status: open
title: Faster bit ops for single-digit positive longs
type: performance
Added file: http://bugs.python.org/file41901/fast_bits.patch

___
Python tracker 

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



[issue26342] Faster bit ops for single-digit positive longs

2016-02-11 Thread STINNER Victor

STINNER Victor added the comment:

fast_bits.patch LGTM. But it would be better to have at least two reviews.

--

___
Python tracker 

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