python:ext4 文件系统中 os.path.exists 的复杂性?
有谁知道 os.path.exists 函数在带有 ext4 文件系统的 python 中的复杂性是多少?
Does anyone know what the complexity of the os.path.exists function is in python with a ext4 filesystem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Ext4(和Ext3)使用的底层目录结构与Ext2 中的完全相同。 Ext3 添加了日记功能,Ext4 改进了该日记功能。日记与你的问题无关。
最初 Ext2 用来将其存储为列表,但这对于大型目录来说当然效率低下。因此它已更改为 B 树的调整版本,称为 HTree 。与标准 B 树不同,HTree 具有恒定的深度,并且每个节点使用哈希映射,因此它的查找复杂度为O(1)。
请参阅:http://ext2.sourceforge.net/2005-ols/paper -html/node3.html
Underlying directory structure used by Ext4 (and Ext3) is exactly the same as in Ext2. Ext3 adds journaling, Ext4 improves that journaling. Journaling is irrelevant to your question.
Originally Ext2 used to store that as list, but that of course was inefficient for large directories. So it's has been changed to tweaked version of B-tree called HTree. Unlike standard B-tree, HTree has constant depth and uses hash-map per node, thus it's lookup complexity is O(1).
See: http://ext2.sourceforge.net/2005-ols/paper-html/node3.html
复杂度很有可能是
O(n)
,其中n是文件系统的深度(例如/将有n=1,/something n=2,...)Chances are good that the complexity is
O(n)
with n being the depth in the filesystem (e.g. / would have n=1, /something n=2, ...)