[issue44711] Optimize type check in pipes.py

2021-07-29 Thread Anton Grübel

Anton Grübel  added the comment:

I'm still super happy to had the chance to contribute a bit to Python and it 
will be available already in version 3.10 <3

Thanks Serhiy & Lukasz!

--

___
Python tracker 

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



[issue44711] Optimize type check in pipes.py

2021-07-29 Thread Łukasz Langa

Łukasz Langa  added the comment:

Due to a non-zero (even if close to zero) likelihood that the change from 
type() comparison to an isinstance() check will change behavior, I merged it to 
3.11 and 3.10 as 3.9 is already pretty far out in its bugfix releases.

Thanks, Anton! ✨  ✨

--
nosy: +lukasz.langa
resolution:  -> fixed
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



[issue44711] Optimize type check in pipes.py

2021-07-28 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 5.0 -> 6.0
pull_requests: +25948
pull_request: https://github.com/python/cpython/pull/27416

___
Python tracker 

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



[issue44711] Optimize type check in pipes.py

2021-07-22 Thread Ma Lin


Ma Lin  added the comment:

> I suppose it is a very old code

I also found a few old code may have performance loss.

memoryview.cast() method was add in Python 3.3.
This code doesn't use memoryview.cast(), which will bring extra memory overhead 
when the amount of data is very large.
https://github.com/python/cpython/blob/v3.10.0b4/Lib/multiprocessing/connection.py#L190-L194

--
nosy: +malin

___
Python tracker 

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



[issue44711] Optimize type check in pipes.py

2021-07-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

See also issue44712.

--

___
Python tracker 

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



[issue44711] Optimize type check in pipes.py

2021-07-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I suppose it is a very old code written when str was a function, not a type 
(thus using type('')) and builtin types were not subclassable (thus not using 
isinstance()).

I once analyzed other similar cases in the stdlib. Seems it is time to revive 
my old patch.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue44711] Optimize type check in pipes.py

2021-07-22 Thread Anton Grübel

Anton Grübel  added the comment:

I know that :) , it is just weird to do also do the type check on an empty 
string, which can be replaced with str directly, but as far as I know it is 
usually better to use isinstance instead of type.

--

___
Python tracker 

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



[issue44711] Optimize type check in pipes.py

2021-07-22 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
nosy: +python-dev
nosy_count: 2.0 -> 3.0
pull_requests: +25833
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/27291

___
Python tracker 

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



[issue44711] Optimize type check in pipes.py

2021-07-22 Thread Eric V. Smith


Eric V. Smith  added the comment:

The difference is that type(cmd) is doing an exact match on the type, while 
isinstance is checking for types or derived types. I don't know if that makes a 
difference here, but it's worth noting.

--
nosy: +eric.smith

___
Python tracker 

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



[issue44711] Optimize type check in pipes.py

2021-07-22 Thread Anton G.


New submission from Anton G. :

When I did some work on typeshed I found some weird syntax in pipes.py.

if type(cmd) is not type(''):

which can easily be changed to

if not isinstance(cmd, str):

There are two occurrences and I will directly create the PR :)

--
components: Library (Lib)
messages: 397995
nosy: anton.gruebel
priority: normal
severity: normal
status: open
title: Optimize type check in pipes.py
type: performance

___
Python tracker 

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