Message407221
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 |
|
| Date |
User |
Action |
Args |
| 2021-11-28 19:21:47 | eryksun | set | recipients:
+ eryksun, paul.moore, tim.golden, zach.ware, steve.dower |
| 2021-11-28 19:21:47 | eryksun | set | messageid: <[email protected]> |
| 2021-11-28 19:21:47 | eryksun | link | issue45919 messages |
| 2021-11-28 19:21:47 | eryksun | create | |
|