Mailing List Archive

[issue43025] Use normal 'i' character to denote imaginary part of complex numbers
Bhuvanesh Bhatt <bhuvaneshbhatt@gmail.com> added the comment:

Nobody these days uses j to represent the imaginary part of complex numbers. Regardless of what Guido wrote earlier, this issue should be fixed.

----------
title: Use normal 'i -> Use normal 'i' character to denote imaginary part of complex numbers
type: -> enhancement
versions: +Python 3.9

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Christian Heimes <lists@cheimes.de> added the comment:

Your statement is not correct. A lot of people use "j" in fields of electrical engineering and signal processing to express the imaginary part. The letter "i" is commonly used for electric current in these fields.

----------
nosy: +christian.heimes

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Eric V. Smith <eric@trueblade.com> added the comment:

Even if we wanted to switch to "i" we'd have to continue to also support "j": there's a ton of existing code that uses it. Since "j" is used by some fields (including my own) for the imaginary part of complex numbers, and since I don't think we want to have two ways to do the same thing, I think this proposal should be objected.

But if you really want to pursue it, I suggest starting a discussion on the python-ideas mailing list.

----------
nosy: +eric.smith

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Emmanuel Arias <eamanu@yaerobi.com> added the comment:

Personally, it's more natural use 'j' for complex number, but it's true that in many math book (or that I used) letter 'i' is used.

Now, it's feasible change i for j on cpython? Asking from my ignorance on this case.

----------
nosy: +eamanu

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Emmanuel Arias <eamanu@yaerobi.com> added the comment:

> Now, it's feasible change i for j on cpython? Asking from my ignorance on this case.

j for i, sorry

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Eric V. Smith <eric@trueblade.com> added the comment:

As I said in msg385648, I don't think it's feasible.

Maybe I'll write a PEP just to get it rejected so we can point to it when this discussion comes up, which it does a few times a year.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Eric V. Smith <eric@trueblade.com> added the comment:

I don't think it really matters what other languages do. We're not designing this from scratch. We need to reflect that state we're in, which is many, many lines of working code using 'j'. I see the two options as: support 'i' and 'j', or break existing code and switch to 'i'. I don't think either option makes sense.

----------
title: Use normal 'i -> Use normal 'i' character to denote imaginary part of complex numbers

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Steven D'Aprano <steve+python@pearwood.info> added the comment:

I think it always helps to look at what other languages do. It doesn't
mean that we must follow them, but it may help us decide that the choice
made in Python 1 was a mistake and it is worth going through the pain of
deprecation, or that it is still justified and we should stick to the
current design. If everyone else is making a different decision, it pays
to at least consider why. If they're making the same decision we did,
that helps justify what we did.

For what it's worth, although my personal preference would be for i, I
think that going through a disruptive deprecation period is not
justified. j is good enough. I haven't got an opinion on supporting both
i and j.

Eric, if you do follow through with writing a PEP, remember that you
have to make the best case that you can for the change. And you might be
surprised: when Guido volunteered me to write the dict addition PEP, I
initially intended it to be rejected. I never expected that it would be
accepted with a change of operator.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Eric V. Smith <eric@trueblade.com> added the comment:

Good point on surveying other languages for a PEP. You're further along in your thinking than I am!

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Mark Dickinson <dickinsm@gmail.com> added the comment:

See also #10562.

Conceivably, we could add support for `i` on parsing (along with adding `cmath.infi` and `cmath.nanj`). We can probably also find a way to extend the format specification to allow use of `i` in place of `j` on output. The harder problem would be changing the repr and str of complex without breaking existing code. I doubt that the OP would be satisfied with the following:

>>> 3 + 4i
(3+4j)

----------
nosy: +mark.dickinson

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Mark Dickinson <dickinsm@gmail.com> added the comment:

> cmath.nanj

That should be cmath.nani, of course. Sorry.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Serhiy Storchaka <storchaka+cpython@gmail.com> added the comment:

Only yesterday I thought about proposing this idea. I used to think using "i" or "j" was a type of local feature, like using a comma or a period as a decimal separator, or different writing for less-or-equal, but it looks like even in the English-speaking world mathematics use "i", and "j" is only used by electric engineers.

Possible argument against the "i" suffix is that its capital form "I" can be confused with the "l" suffix for longs (but it is no longer applicable in Python 3) and digit "1". Although there is more similarity between "l" and "1" them between them both and "I", and there are other pairs of potentially confusing characters: "O" (for octals) and "0", "B" (for binaries) and "8".

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Mark Dickinson <dickinsm@gmail.com> added the comment:

Serhiy: what *specific* proposal were you considering? If your proposal includes changing the complex str/repr to use "i" instead of "j", how do you propose to address the backwards compatibility problem?

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Serhiy Storchaka <storchaka+cpython@gmail.com> added the comment:

Just making the parser (and the complex constructor) recognizing "i" as well as "j" as complex number suffix. Others already proposed more complex changes like adding options for formatting complex numbers, but I did not though about it. It is just a coincidence that I though about this idea in the same day as the OP opened the issue.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Change by Serhiy Storchaka <storchaka+cpython@gmail.com>:


----------
versions: +Python 3.10 -Python 3.9

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Mark Dickinson <dickinsm@gmail.com> added the comment:

[Serhiy]

> Just making the parser [...] recognizing "i" as well as "j" as complex number suffix.

Okay, thanks. I doubt that that will be enough to silence the repeated requests: people are still going to complain that the value that was entered as `1i` is being displayed as `1j`. I don't see a sane path towards changing that.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Raymond Hettinger <raymond.hettinger@gmail.com> added the comment:

Unfortunately, this ship sailed a long time ago. Changing it now would create more problems that it solves.

> I doubt that that will be enough to silence the repeated requests:
> people are still going to complain that the value that was entered
> as `1i` is being displayed as `1j`. I don't see a sane path
> towards changing that.

Exactly this.

----------
nosy: +rhettinger

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Mark Dickinson <dickinsm@gmail.com> added the comment:

@Eric: Are you okay with closing this issue, or do you think we should leave it open as a reminder to write that PEP?

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue43025] Use normal 'i' character to denote imaginary part of complex numbers [ In reply to ]
Eric V. Smith <eric@trueblade.com> added the comment:

Thanks, Mark. I'll just close it now. I've made a reminder about the PEP, but not sure when/if I'll get to it.

----------
resolution: -> rejected
stage: -> resolved
status: open -> closed

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue43025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com