Skip to content

Replace _pysqlite_long_from_int64() with PyLong_FromLongLong()#16882

Merged
serhiy-storchaka merged 1 commit into
python:masterfrom
sir-sigurd:pysqlite_long_from_int64
Oct 23, 2019
Merged

Replace _pysqlite_long_from_int64() with PyLong_FromLongLong()#16882
serhiy-storchaka merged 1 commit into
python:masterfrom
sir-sigurd:pysqlite_long_from_int64

Conversation

@sir-sigurd

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread Modules/_sqlite/util.c
PyObject *
_pysqlite_long_from_int64(sqlite_int64 value)
{
# if SIZEOF_LONG_LONG < 8

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unneeded since long long is guaranteed to be at least 64-bit.

Comment thread Modules/_sqlite/util.c
Comment on lines -115 to -119
# if SIZEOF_LONG < SIZEOF_LONG_LONG
if (value > LONG_MAX || value < LONG_MIN)
return PyLong_FromLongLong(value);
# endif
return PyLong_FromLong(Py_SAFE_DOWNCAST(value, sqlite_int64, long));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think that using PyLong_FromLong() for small values on 32 bit platforms provides speed-up, but if it does that should be done in PyLong_FromLongLong().
Moreover AFAIK long is 32 bit on 64 bit Windows, so that condition is not compiled out.

@eamanu eamanu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM but you should be open a issue on bpo to more discussion

@serhiy-storchaka
serhiy-storchaka merged commit b6f5b9d into python:master Oct 23, 2019
@sir-sigurd
sir-sigurd deleted the pysqlite_long_from_int64 branch October 23, 2019 08:16
jacobneiltaylor pushed a commit to jacobneiltaylor/cpython that referenced this pull request Dec 5, 2019
shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request Jan 31, 2020
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.

5 participants