This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients ammar2, gregory.p.smith, malin, serhiy.storchaka, sir-sigurd, vstinner, zach.ware
Date 2019-09-19.09:53:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1568886805.8.0.216496625364.issue38205@roundup.psfhosted.org>
In-reply-to
Content
I prefer to keep it a macro. The compiler does not know that it is never executed, so it can generate a suboptimal code.

While it is a macro, it can be made a no-op, or even with compiler-specific instructions like __builtin_unreachable. This can help the compiler to generate more optimal code. For example, the popular idiom:

    switch (kind) {
    case PyUnicode_1BYTE_KIND: {
        ...
        break;
    }
    case PyUnicode_2BYTE_KIND: {
        ...
        break;
    }
    case PyUnicode_4BYTE_KIND: {
        ...
        break;
    }
    default: Py_UNREACHABLE();
    }

could be compiled to the code equivalent to:

    if (kind == PyUnicode_1BYTE_KIND) {
        ...
        break;
    }
    else if (kind == PyUnicode_2BYTE_KIND) {
        ...
        break;
    }
    else { // assuming (kind == PyUnicode_4BYTE_KIND)
        ...
        break;
    }
History
Date User Action Args
2019-09-19 09:53:25serhiy.storchakasetrecipients: + serhiy.storchaka, gregory.p.smith, vstinner, zach.ware, malin, ammar2, sir-sigurd
2019-09-19 09:53:25serhiy.storchakasetmessageid: <1568886805.8.0.216496625364.issue38205@roundup.psfhosted.org>
2019-09-19 09:53:25serhiy.storchakalinkissue38205 messages
2019-09-19 09:53:25serhiy.storchakacreate