[issue46705] Memory optimization for set.issubset

2022-02-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It will be even more efficient after applying a set.intersection() optimization in issue43464. -- ___ Python tracker ___

[issue46705] Memory optimization for set.issubset

2022-02-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: See also issue18032. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46705] Memory optimization for set.issubset

2022-02-10 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Would not testing len(self.difference(other)) == 0 > be more efficient? Yes, I think so. -- Added file: https://bugs.python.org/file50620/instrument_issubset.py ___ Python tracker

[issue46705] Memory optimization for set.issubset

2022-02-10 Thread Jack Nguyen
Change by Jack Nguyen : -- keywords: +patch pull_requests: +29432 stage: -> patch review pull_request: https://github.com/python/cpython/pull/31267 ___ Python tracker ___

[issue46705] Memory optimization for set.issubset

2022-02-10 Thread Jack Nguyen
Jack Nguyen added the comment: As you say, which implementation performs better likely depends on the nature of the sets. I would suspect that using set.difference won't be substantially faster than using set.intersection in the best case, but it would be much slower if len(self) is much

[issue46705] Memory optimization for set.issubset

2022-02-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Would not testing len(self.difference(other)) == 0 be more efficient? Making a copy of a set and removing elements one by one may be faster than add elements one by one, because we only need to allocate a single chunk of memory for a set. It depends on

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Raymond Hettinger
Change by Raymond Hettinger : Added file: https://bugs.python.org/file50615/instrument_issubset.py ___ Python tracker ___ ___

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Raymond Hettinger
Change by Raymond Hettinger : Removed file: https://bugs.python.org/file50614/instrument_issubset.py ___ Python tracker ___ ___

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Raymond Hettinger
Change by Raymond Hettinger : Removed file: https://bugs.python.org/file50613/instrument_issubset.py ___ Python tracker ___ ___

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: I've run a few more experiments and this looks like a net win more often than not. Go ahead and submit a PR so we can evaluate it further. -- Added file: https://bugs.python.org/file50614/instrument_issubset.py

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: We care more about the running speed than the memory usage. Since sets only store pointers to data, they are typically smaller than the data they refer to. I've attached some instrumentation code for running experiments to verify the workload under

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Raymond Hettinger
Change by Raymond Hettinger : -- versions: -Python 3.10, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker ___ ___

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Dennis Sweeney
Change by Dennis Sweeney : -- nosy: +rhettinger, serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Jack Nguyen
New submission from Jack Nguyen : I noticed that the set.issubset cpython implementation casts its iterable argument to a set. In some cases, casting the whole iterable to a set is unnecessary (see https://bugs.python.org/issue18032). Although the latter suggestion is to perform early