Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-28754: AC on bisect. #177

Closed

Conversation

JulienPalard
Copy link
Member

@JulienPalard JulienPalard commented Feb 19, 2017

@JulienPalard JulienPalard changed the title bpo28754: AC on bisect. bpo-28754: AC on bisect. Feb 19, 2017
Copy link
Member

@methane methane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
But please wait approval from expert.
(@rhettinger is listed on http://cpython-devguide.readthedocs.io/experts.html)

@@ -6,6 +6,39 @@ Converted to C by Dmitry Vasiliev (dima at hlabs.spb.ru).
#define PY_SSIZE_T_CLEAN
#include "Python.h"

static int
ssize_t_converter(PyObject *obj, void *ptr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ssize_t_converter is not used for parsing arguments. It is used only in optional_ssize_t_converter. Wouldn't be better to inline it?


a: object
x: object
lo: Py_ssize_t(c_default='0') = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c_default='0' is redundant.



/*[clinic input]
bisect.bisect_right
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the return converter for simplifying the code.

bisect.bisect_right -> Py_ssize_t

The body of bisect_bisect_right_impl() would be just:

return internal_bisect_right(a, x, lo, hi);

@@ -186,6 +186,11 @@ def test_optionalSlicing(self):
self.assertTrue(data[ip-1] <= elem)
self.assertEqual(ip, max(lo, min(hi, expected)))

def test_hi_backcompatbility(self):
for func, data, elem, expected in self.precomputedCases:
self.assertEqual(func(data, elem, 0, -1),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't check that passing -1 and None is the same as not specifying the hi argument. Compare results with func(data, elem).

@rhettinger rhettinger self-assigned this Apr 5, 2017
@rhettinger
Copy link
Contributor

I don't want the pure python API to change at all. It is a long standing API and there is nothing wrong with it. Also, passing it -1 here as a special value makes real code less readable. Further, the change slightly slows down the case where high is specified. In a high performance building block module, we shouldn't add in unnecessary checks.

@brettcannon
Copy link
Member

To try and help move older pull requests forward, we are going through and backfilling 'awaiting' labels on pull requests that are lacking the label. Based on the current reviews, the best we can tell in an automated fashion is that a core developer requested changes to be made to this pull request.

If/when the requested changes have been made, please leave a comment that says, I have made the requested changes; please review again. That will trigger a bot to flag this pull request as ready for a follow-up review.

akruis pushed a commit to akruis/cpython that referenced this pull request Nov 1, 2018
…ute()

I missed the C-fame case, when I changed the frame-function ref counting
in Stackless issue python#117.
@JulienPalard JulienPalard deleted the issue28754-ac-bisect branch June 16, 2019 14:05
jaraco pushed a commit that referenced this pull request Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants