<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/ext/pathname/lib/pathname.rb, branch v3_2_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>[ruby/pathname] [Misc #19155] [DOC] Addion of absolute paths</title>
<updated>2022-12-03T15:53:20+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2022-12-03T15:31:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b8a73e704ddc77db36317dda293e99fb0ee641f4'/>
<id>b8a73e704ddc77db36317dda293e99fb0ee641f4</id>
<content type='text'>
https://github.com/ruby/pathname/commit/3cb5ed2576
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/pathname/commit/3cb5ed2576
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/pathname] Fix `autoload` of `FileUtils`</title>
<updated>2022-07-27T12:05:10+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2022-07-27T05:11:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=64c8291c7e7b6c5e1357c48ab4edb0f434ef1739'/>
<id>64c8291c7e7b6c5e1357c48ab4edb0f434ef1739</id>
<content type='text'>
Should not be `Pathname::FileUtils`.

https://github.com/ruby/pathname/commit/d1eb366e73
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Should not be `Pathname::FileUtils`.

https://github.com/ruby/pathname/commit/d1eb366e73
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge https://github.com/ruby/pathname/pull/8 for pathname</title>
<updated>2022-05-20T09:36:01+00:00</updated>
<author>
<name>Hiroshi SHIBATA</name>
<email>hsbt@ruby-lang.org</email>
</author>
<published>2022-05-20T09:36:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c83ec3aba72aeb50df3b3188b6a009e93f11494a'/>
<id>c83ec3aba72aeb50df3b3188b6a009e93f11494a</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[Feature #16972] Add mode: option to Pathname#mkpath</title>
<updated>2021-08-31T02:53:41+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2020-06-21T02:33:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=2dd26bed86f721ed1982d00c3a0bd5ed37568e96'/>
<id>2dd26bed86f721ed1982d00c3a0bd5ed37568e96</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Faster Pathname FileUtils methods</title>
<updated>2021-08-30T06:18:11+00:00</updated>
<author>
<name>schneems</name>
<email>richard.schneeman+foo@gmail.com</email>
</author>
<published>2020-10-23T14:34:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=51070ee5c4e83a4faa0feb72f08d1d9fef18b016'/>
<id>51070ee5c4e83a4faa0feb72f08d1d9fef18b016</id>
<content type='text'>
Currently when calling any of the "FileUtils" methods on pathname `require` is called every time even though that library might already be loaded. This is slow:

We can speed it up by either checking first if the constant is already defined, or by using autoload.

Using defined speeds up the action by about 300x and using autoload is about twice as fast as that (600x faster than current require method).

I'm proposing we use autoload:

```ruby
require 'benchmark/ips'

Benchmark.ips do |x|
  autoload(:FileUtils, "fileutils")
  x.report("require") { require 'fileutils' }
  x.report("defined") { require 'fileutils' unless defined?(FileUtils) }
  x.report("autoload") { FileUtils }

  x.compare!
end

# Warming up --------------------------------------
#              require     3.624k i/100ms
#              defined     1.465M i/100ms
#             autoload     2.320M i/100ms
# Calculating -------------------------------------
#              require     36.282k (± 2.4%) i/s -    184.824k in   5.097153s
#              defined     14.539M (± 2.0%) i/s -     73.260M in   5.041161s
#             autoload     23.100M (± 1.9%) i/s -    115.993M in   5.023271s

# Comparison:
#             autoload: 23099779.2 i/s
#              defined: 14538544.9 i/s - 1.59x  (± 0.00) slower
#              require:    36282.3 i/s - 636.67x  (± 0.00) slower
```

Because this autoload is scoped to Pathname it will not change the behavior of existing programs that are not expecting FileUtils to be loaded yet:

```
ruby -rpathname -e "class Pathname; autoload(:FileUtils, 'fileutils'); end; puts FileUtils.exist?"
Traceback (most recent call last):
-e:1:in `&lt;main&gt;': uninitialized constant FileUtils (NameError)
```</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently when calling any of the "FileUtils" methods on pathname `require` is called every time even though that library might already be loaded. This is slow:

We can speed it up by either checking first if the constant is already defined, or by using autoload.

Using defined speeds up the action by about 300x and using autoload is about twice as fast as that (600x faster than current require method).

I'm proposing we use autoload:

```ruby
require 'benchmark/ips'

Benchmark.ips do |x|
  autoload(:FileUtils, "fileutils")
  x.report("require") { require 'fileutils' }
  x.report("defined") { require 'fileutils' unless defined?(FileUtils) }
  x.report("autoload") { FileUtils }

  x.compare!
end

# Warming up --------------------------------------
#              require     3.624k i/100ms
#              defined     1.465M i/100ms
#             autoload     2.320M i/100ms
# Calculating -------------------------------------
#              require     36.282k (± 2.4%) i/s -    184.824k in   5.097153s
#              defined     14.539M (± 2.0%) i/s -     73.260M in   5.041161s
#             autoload     23.100M (± 1.9%) i/s -    115.993M in   5.023271s

# Comparison:
#             autoload: 23099779.2 i/s
#              defined: 14538544.9 i/s - 1.59x  (± 0.00) slower
#              require:    36282.3 i/s - 636.67x  (± 0.00) slower
```

Because this autoload is scoped to Pathname it will not change the behavior of existing programs that are not expecting FileUtils to be loaded yet:

```
ruby -rpathname -e "class Pathname; autoload(:FileUtils, 'fileutils'); end; puts FileUtils.exist?"
Traceback (most recent call last):
-e:1:in `&lt;main&gt;': uninitialized constant FileUtils (NameError)
```</pre>
</div>
</content>
</entry>
<entry>
<title>Optimize Pathname#relative? / absolute?</title>
<updated>2020-09-14T18:18:23+00:00</updated>
<author>
<name>Marc-Andre Lafortune</name>
<email>github@marc-andre.ca</email>
</author>
<published>2019-04-03T19:22:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=39312cf4d6c2ab3f07d688ad1a467c8f84b58db0'/>
<id>39312cf4d6c2ab3f07d688ad1a467c8f84b58db0</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Document limitation of Pathname#relative_path_from [ci skip]</title>
<updated>2020-09-02T17:34:33+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2020-09-02T17:34:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=cc5b7ed1dccc6a5cffa5c52778c6db8794722404'/>
<id>cc5b7ed1dccc6a5cffa5c52778c6db8794722404</id>
<content type='text'>
This method is explicitly documented to not access the filesystem,
and the only way to get the correct behavior for a case where the
filesystem's case sensitivity differs from the operating system
default would be to access the filesystem.

Fixes [Bug #15417]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This method is explicitly documented to not access the filesystem,
and the only way to get the correct behavior for a case where the
filesystem's case sensitivity differs from the operating system
default would be to access the filesystem.

Fixes [Bug #15417]
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove unnecessary double bangs from Pathname#root?</title>
<updated>2019-12-17T05:14:54+00:00</updated>
<author>
<name>Masataka Pocke Kuwabara</name>
<email>kuwabara@pocke.me</email>
</author>
<published>2019-12-08T15:48:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=8f52604b478fee5243080116b8e62f0c1f5cb9a0'/>
<id>8f52604b478fee5243080116b8e62f0c1f5cb9a0</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Pathname#relative_path_from uses is_a?</title>
<updated>2018-12-18T03:09:54+00:00</updated>
<author>
<name>akr</name>
<email>akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2018-12-18T03:09:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=78dc3da299f49eec2783190ad72812852750f40e'/>
<id>78dc3da299f49eec2783190ad72812852750f40e</id>
<content type='text'>
I reconsidered because simpler code would have better maintainablity.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I reconsidered because simpler code would have better maintainablity.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>Pathname#relative_path_from compatible with mock.</title>
<updated>2018-12-16T12:26:52+00:00</updated>
<author>
<name>akr</name>
<email>akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2018-12-16T12:26:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4cf828632f3e2411b4c141fb30b2edf4844351fa'/>
<id>4cf828632f3e2411b4c141fb30b2edf4844351fa</id>
<content type='text'>
[Fix GH-2049]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Fix GH-2049]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
</feed>
