Skip to content

bpo-27961: Replace PY_LONG_LONG with long long#15386

Merged
serhiy-storchaka merged 1 commit into
python:masterfrom
sir-sigurd:py-long-long
Oct 21, 2019
Merged

bpo-27961: Replace PY_LONG_LONG with long long#15386
serhiy-storchaka merged 1 commit into
python:masterfrom
sir-sigurd:py-long-long

Conversation

@sir-sigurd

@sir-sigurd sir-sigurd commented Aug 22, 2019

Copy link
Copy Markdown
Contributor

Comment thread Tools/clinic/clinic.py Outdated

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 decided to remove this cast as it's unneeded.

@aeros aeros Aug 27, 2019

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.

I decided to remove this cast as it's unneeded.

Any idea as to why this cast was previously needed?

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.

@serhiy-storchaka you committed this code in 32d96a2. Does it make sense to you to remove this cast?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It was copied from Python/getargs.c.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer to keep the explicit cast, since long long is an uncommon type and I prefer to avoid bad surprises on some platforms.

@sir-sigurd sir-sigurd Aug 27, 2019

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.

@vstinner I don't really see a problem here, because implicit conversion of integers of the same signedness is well defined and always lossless. If it's so important it can be rewritten as:

if ({paramname} == -1LL && PyErr_Occurred()) {{{{

In that case there are no casts at all.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok.

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.

I don't really see a problem here, because implicit conversion of integers of the same signedness is well defined and always lossless

@vstinner @serhiy-storchaka So is this okay universally across the C-API or is it different in other areas? Of course it wouldn't be worth a PR on it's own since it's more of a conventional/styling decision, I just want to know in case I see a similar implicit integer conversion (signed -> signed or unsigned -> unsigned) without the cast in another PR or if the issue comes up again.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have no idea. The C language remains partially a mystery to me.

@aeros aeros Oct 21, 2019

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.

@vstinner

I have no idea. The C language remains partially a mystery to me.

If the C language is partially a mystery even to you, what hope do the rest of us mere mortals have? ;)

@epicfaace epicfaace 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.

Do you know why the build is failing on azure pipelines?

@sir-sigurd

Copy link
Copy Markdown
Contributor Author

Not sure why it's failed, but seems OK now.

Comment thread Lib/test/clinic.test
goto exit;
}
a = PyLong_AsLongLong(args[0]);
if (a == (PY_LONG_LONG)-1 && PyErr_Occurred()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer to keep the explicit cast.

@serhiy-storchaka serhiy-storchaka merged commit a9ed91e into python:master Oct 21, 2019
@sir-sigurd sir-sigurd deleted the py-long-long branch October 21, 2019 06:56
@vstinner

Copy link
Copy Markdown
Member

Thanks @sir-sigurd for the cleanup :-)

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

Labels

skip news type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants