[issue44803] change tracemalloc.BaseFilter to an abstract class

2021-08-05 Thread Anton Grübel

Anton Grübel  added the comment:

Even it is a private method, it is essential, when you use 
Snapshot.filter_traces(). Creating a Filter without implementing this method 
will just result in a runtime error.

https://github.com/python/cpython/blob/029cb4a6adacb650dbfc8ea71d2875ab771fe92e/Lib/tracemalloc.py#L442-L451

For me it feels like a bad practice to just recommend the developer to 
implement this method instead of enforcing it. Why is there a possibility to 
state clearly that a class is an abstract class and not use it? Even PEP20 
states, "Explicit is better than implicit."

So why is there a way to create an abstract class in Python, just for fun? I 
don't think so, it is to make the intent very clear. As said, there is probably 
a lot of old code laying around in Python, which could be modernized by using 
functionality of newer Python versions, so why not change it? Is there actually 
any drawback in defining this class as an abstract class or do you actually 
gain more, because everyone directly understands that an abstract method has to 
be implemented in the subclass.

@Lukasz: if you ask me, I would change all of them, but I'm definitely lacking 
the skill and experience to find all those flaws and fix them. I'm happy to 
help and for me making code better even it is small is always appreciated, if 
you always think it is not worth the trouble or nothing really to gain, then it 
will stay that way and more and more of those constructs will arise. In Germany 
we have a saying, small cattle also make muck :D

But thanks for taking a look, even it was not worth the trouble. I had fun  
creating the PR, but you can just do what you like with it.

--

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



[issue44803] change tracemalloc.BaseFilter to an abstract class

2021-08-01 Thread Anton Grübel

Change by Anton Grübel :


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

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



[issue44803] change tracemalloc.BaseFilter to an abstract class

2021-08-01 Thread Anton Grübel

New submission from Anton Grübel :

during some work on typeshed I found the BaseFilter class in tracemalloc and it 
totally looks like and is used as a typical abstract class.

I will also directly create the PR :) if you think I'm missing something, I'm 
happy to hear some other thoughts.

--
components: Library (Lib)
messages: 398699
nosy: anton.gruebel
priority: normal
severity: normal
status: open
title: change tracemalloc.BaseFilter to an abstract class
type: enhancement
versions: Python 3.11

___
Python tracker 
<https://bugs.python.org/issue44803>
___
___
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 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 
<https://bugs.python.org/issue44711>
___
___
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 
<https://bugs.python.org/issue44711>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com