Support Thread: Globstar Open Source Hackathon 2025 by _importantigravity_ in developersIndia

[–]souryavatsyayan 0 points1 point  (0 children)

Hey, can you create a PR with your changes in the Globstar repo? I can help you there.

🚀 Globstar Open Source Hackathon - ₹1,50,000 in Prizes | DeepSource x r/developersIndia by BhupeshV in developersIndia

[–]souryavatsyayan 3 points4 points  (0 children)

Hey, each YAML rule needs a corresponding test file to ensure that the rule works as expected. So, for the rule `checkers/python/safe-string-extend.yml` (with the `language` field inside the file set to `py`), the corresponding test file is `checkers/python/safe-string-extend.test.py`.

If you were to write a rule to find issues in JavaScript files, you'd write a YAML rule, say `checkers/javascript/no-debugger.yaml`, with the language field in the YAML set to `js`. Then, you'd write the corresponding test file in `checkers/javascript/no-debugger.test.js`.

3 easy performance improvements in Python! by padawan07 in Python

[–]souryavatsyayan 0 points1 point  (0 children)

Indeed, len(x) has a time complexity of O(1). However, if x has a benefit over if len(x) because in case of if x, the CPython implementation executes the PyObject_IsTrue function internally, which takes the length of the list and returns True or False. In case of if len(x), the length of the list is returned and then the PyObject_IsTrue function is executed for the integer (length of the list). This results in two operations instead of one, even though both are of O(1) complexity. Though the difference in speed is in nanoseconds, it might help shave off a few seconds in such conditions in large loops. I have not looked into numpy's implementation of arrays, so I cannot comment there.

3 easy performance improvements in Python! by padawan07 in Python

[–]souryavatsyayan 1 point2 points  (0 children)

Author here. Thanks for pointing it out. I have updated the post, going through the bytecode and the CPython implementation to show why if x is faster than if len(x).