➜

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 eryksun
Recipients eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Date 2021-11-28.19:21:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <[email protected]>
In-reply-to
Content
During startup, is_valid_fd() in Python/pylifecycle.c is called to validate stdin, stdout, and stderr. Performance isn't critical here, but every bit helps in reducing startup time. In my tests, implementing this check in Windows via GetFileType((HANDLE)_get_osfhandle(fd)) is 5-6 times faster than close(dup(fd)). For example:

#if defined(MS_WINDOWS)
    HANDLE hfile;
    _Py_BEGIN_SUPPRESS_IPH
    hfile = (HANDLE)_get_osfhandle(fd);
    _Py_END_SUPPRESS_IPH
    return (hfile != INVALID_HANDLE_VALUE &&
              GetFileType(hfile) != FILE_TYPE_UNKNOWN);
#endif
History
Date User Action Args
2021-11-28 19:21:47eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower
2021-11-28 19:21:47eryksunsetmessageid: <[email protected]>
2021-11-28 19:21:47eryksunlinkissue45919 messages
2021-11-28 19:21:47eryksuncreate