[issue46721] Optimize set.issuperset() for non-set argument

2022-04-06 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
dependencies:  -Use-after-free by mutating set during set operations
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



[issue46721] Optimize set.issuperset() for non-set argument

2022-04-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset a69a4a917c436579c2c4112081ea86a70f1f05d3 by Serhiy Storchaka in 
branch 'main':
bpo-46721: Optimize set.issuperset() for non-set arguments (GH-31280)
https://github.com/python/cpython/commit/a69a4a917c436579c2c4112081ea86a70f1f05d3


--

___
Python tracker 

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



[issue46721] Optimize set.issuperset() for non-set argument

2022-02-11 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
assignee:  -> rhettinger

___
Python tracker 

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



[issue46721] Optimize set.issuperset() for non-set argument

2022-02-11 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
dependencies: +Use-after-free by mutating set during set operations

___
Python tracker 

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



[issue46721] Optimize set.issuperset() for non-set argument

2022-02-11 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The new code is similar to the code of set.isdisjoint(), so we can share the 
code if generalize it.

--

___
Python tracker 

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



[issue46721] Optimize set.issuperset() for non-set argument

2022-02-11 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue46721] Optimize set.issuperset() for non-set argument

2022-02-11 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

If the argument of set.issuperset() is not a set, it is first converted to a 
set. It is equivalent to the following code:

if not isinstance(other, (set, frozenset)):
other = set(other)
# The following is equivalent to:
# return set.issubset(other, self)
for x in other:
if x not in self
return False
return True

Two drawbacks of this algorithm:

1. It creates a new set, which takes O(len(other)) time and consumes 
O(len(set(other))) memory.
2. It needs to iterate other to the end, even if the result is known earlier.

The proposed PR straightforward the code. The C code is now larger, but it no 
longer need additional memory, performs less operations and can stop earlier.

--
components: Interpreter Core
messages: 413075
nosy: rhettinger, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Optimize set.issuperset() for non-set argument
type: performance
versions: Python 3.11

___
Python tracker 

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