View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0004217 | FreeCAD | Bug | public | 2019-12-06 02:56 | 2021-12-20 01:43 |
Reporter | apelleti | Assigned To | chennes | ||
Priority | normal | Severity | tweak | Reproducibility | N/A |
Status | confirmed | Resolution | open | ||
Target Version | 0.20 | ||||
Summary | 0004217: Simple perf improvement: avoid 'if somekey in mydict.keys()' | ||||
Description | This ticket is a suggestion to fix some very simple (common) coding errors that can seriously degrade performance in python. Doing a python dictionary hash lookup the recommended way:
Doing a python dictionary hash lookup the wrong way:
====== Performance comparison:
Runtime=0.07 seconds to test 200k keys exist in the dictionary of 200k entries.----------
Runtime=11min 29sec.....10000 times slower!! :-(See "additional info" for a partial list. | ||||
Steps To Reproduce | N/A | ||||
Additional Information | Here's a partial list of potential fixes, using a rudimentary grep to search the codebase for occurrences. DISCLAIMER: likely a few false-positives.
| ||||
Tags | No tags attached. | ||||
FreeCAD Information | OS: macOS 10.14 Word size of OS: 64-bit Word size of FreeCAD: 64-bit Version: 0.18.16146 (Git) Build type: Release Branch: (HEAD detached at 0.18.4) Hash: 980bf9060e28555fecd9e3462f68ca74007b70f8 Python version: 3.6.7 Qt version: 5.6.2 Coin version: 4.0.0a OCC version: 7.3.0 Locale: English/Canada (en_CA) | ||||
|
@apelleti : please open a forum topic and cross-link with this ticket (per the guidelines in the huge yellow box on the top of the page). BTW : your command line will be better written like |
|
Forum thread https://forum.freecadweb.org/viewtopic.php?f=3&t=41483 |
|
These issues do exist, and simply represent a misunderstanding on the part of the original programmer on what exactly they are asking Python to do. With the exception of the false positives (e.g. where a container's name contains the word "keys") these can all be replaced wholesale without concern that we are breaking something. Best to remove all of them, so later copy-and-paste programmers don't inherit the performance penalty. |
|
This ticket has been migrated to GitHub as issue 6015. |
Date Modified | Username | Field | Change |
---|---|---|---|
2019-12-06 02:56 | apelleti | New Issue | |
2019-12-06 11:00 | openBrain | Tag Attached: #post-to-forum | |
2019-12-06 11:01 | openBrain | Status | new => feedback |
2019-12-06 11:01 | openBrain | Category | General => Patch |
2019-12-06 11:01 | openBrain | Note Added: 0013877 | |
2020-01-14 18:14 | Kunda1 | Note Added: 0014074 | |
2020-01-14 18:14 | Kunda1 | Tag Detached: #post-to-forum | |
2020-01-14 18:14 | Kunda1 | Tag Attached: #pending-forum | |
2020-01-14 20:02 | Kunda1 | Note Edited: 0014074 | |
2021-02-06 06:49 | abdullah | Target Version | => 0.20 |
2021-12-17 05:03 | chennes | Assigned To | => chennes |
2021-12-17 05:03 | chennes | Status | feedback => confirmed |
2021-12-17 05:03 | chennes | Note Added: 0016110 | |
2021-12-17 05:04 | chennes | Tag Detached: #pending-forum | |
2021-12-17 05:04 | chennes | Category | Patch => Bug |
2021-12-20 01:43 | chennes | Description Updated | |
2021-12-20 01:43 | chennes | Additional Information Updated |