-
-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Identify sockets #177
Identify sockets #177
Conversation
identify/identify.py
Outdated
return {DIRECTORY} | ||
if os.path.islink(path): | ||
return {SYMLINK} | ||
if stat.S_ISSOCK(os.stat(path).st_mode): | ||
return {SOCKET} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should do a single os.stat
call and then decide based on that -- as it is right now this is going to do at least 4 stat calls to determine these tags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean isdir
, islink
, and others do os.stat
under the hood?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, and lexists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For os.access
do you recommend hand-rolling something that supports both posix & windows or leaving it as-is? Also for some of the public functions that check if a file exists & other properties, should I remove those checks (because the caller checks them) to save on stat calls, or preserve the behavior because they're public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went with erring towards leaving more code as-is but lmk if there's anything else straightforward that I missed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is part of #72