[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-ideas
Subject:    [Python-ideas] Re: pathlib enhancements
From:       Todd <toddrjen () gmail ! com>
Date:       2021-01-07 16:13:58
Message-ID: CAFpSVpKUJaXwAQ0BE=6EQ4Q9QkG8YASqgrAZmq2uvG=tpA40mg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Thu, Jan 7, 2021, 10:54 Sven R. Kunze <srkunze@mail.de> wrote:

> I split my answers up to address different issues in different threads.
>
>
> On 31.12.20 15:32, Todd wrote:
>
> Hi Sven,
>
> Thanks for your support and feedback.
>
>
> On Thu, Dec 31, 2020, 07:23 Sven R. Kunze <srkunze@mail.de> wrote:
>
>> Hi Todd,
>>
>> my comments below. Also would offer my time for reviewing/testing if
>> wanted.
>>
>>
>> On 22.11.20 20:53, Todd wrote:
>>
>> I know enhancements to pathlib gets brought up occasionally, but it
>> doesn't look like anyone has been willing to take the initiative and see
>> things through to completion.  I am willing to keep the ball rolling here
>> and even implement these myself.  I have some suggestions and I would like
>> to discuss them.  I don't think any of them are significant enough to
>> require a pep.  These can be split it into independent threads if anyone
>> prefers.
>>
>> 1. copy
>>
>> The big one people keep bringing up that I strongly agree on is a "copy"
>> method.  This is really the only common file manipulation task that
>> currently isn't possible.  You can make files, read them, move them, delete
>> them, create directories, even do less common operations like change owners
>> or create symlinks or hard links.
>>
>> I really would appreciate that one. If I could through in another detail
>> which we needed a lot:
>>
>> - atomic_copy or copy(atomic=True) whatever form you prefer
>>
>> It is not as easy to achieve as it may look on the first sight.
>> Especially when it comes to tempfiles and permissions. The use cases of
>> atomic copy included scenarios for multiple parallel access of files like
>> caches in web development.
>>
>
> Is there already support for atomic writes in the standard library?  I am
> not planning on implementing anything new, only exposing existing
> functionality.  Adding atomic operations to the stslib would likely require
> a pep and substantial discussion of API and implementation.  I don't really
> have the background to do that.
>
>
> So far I didn't find any of this implemented in the stdlib but please
> correct me if I am wrong.
>
>
> As far as I know, one working pattern would be
>
> 1. creating a file or the directory structure using tempfile
> 2. then setting permissions from the original directory object
> 3. and finally moving it to its final destination (path and name)
>
> The last part is done atomically at least in Linux (rename) and Windows
> (ReplaceFile).
>
> Especially setting permission an easy oversight which can cause issues
> e.g. with xsendfile.
>
>
> What would be the steps to do get it done?
>
This is outside my area of expertise and is far outside the scope of my
proposal, so it really needs its own thread.  I think there have
periodically been requests for atomic file operations on this mailing list,
so the first step would be to search the mailing list and see what
prevented those from going anywhere.

>

[Attachment #5 (text/html)]

<div dir="auto"><br><br><div class="gmail_quote" dir="auto"><div dir="ltr" \
class="gmail_attr">On Thu, Jan 7, 2021, 10:54 Sven R. Kunze &lt;<a \
href="mailto:srkunze@mail.de">srkunze@mail.de</a>&gt; wrote:<br></div><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">  
    
  
  <div>
    <p>I split my answers up to address different issues in different
      threads.</p>
    <p><br>
    </p>
    <div>On 31.12.20 15:32, Todd wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="auto">
        <div>Hi Sven,
          <div dir="auto"><br>
          </div>
          <div dir="auto">Thanks for your support and feedback.</div>
          <br>
          <br>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">On Thu, Dec 31, 2020,
              07:23 Sven R. Kunze &lt;<a href="mailto:srkunze@mail.de" \
target="_blank" rel="noreferrer">srkunze@mail.de</a>&gt; wrote:<br>  </div>
            <blockquote class="gmail_quote">
              <div>
                <p>Hi Todd,<br>
                </p>
                <p>my comments below. Also would offer my time for
                  reviewing/testing if wanted.<br>
                </p>
                <p><br>
                </p>
                <div>On 22.11.20 20:53, Todd wrote:<br>
                </div>
                <blockquote type="cite">
                  <div dir="ltr">I know enhancements to pathlib gets
                    brought up occasionally, but it doesn&#39;t look like
                    anyone has been willing to take the initiative and
                    see things through to completion.   I am willing to
                    keep the ball rolling here and even implement these
                    myself.   I have some suggestions and I would like to
                    discuss them.   I don&#39;t think any of them are
                    significant enough to require a pep.   These can be
                    split it into independent  threads if anyone prefers.
                    <div><br>
                    </div>
                    <div>1. copy</div>
                    <div><br>
                    </div>
                    <div>The big one people keep bringing up that I
                      strongly agree on is a &quot;copy&quot; method.   This is
                      really the only common file manipulation task that
                      currently isn&#39;t possible.   You can make files,
                      read them, move them, delete them, create
                      directories, even do less common operations like
                      change owners or create symlinks or hard links.  </div>
                    <div><br>
                    </div>
                  </div>
                </blockquote>
                <p>I really would appreciate that one. If I could
                  through in another detail which we needed a lot:</p>
                <p>- atomic_copy or copy(atomic=True) whatever form you
                  prefer<br>
                </p>
                <p>It is not as easy to achieve as it may look on the
                  first sight. Especially when it comes to tempfiles and
                  permissions. The use cases of atomic copy included
                  scenarios for multiple parallel access of files like
                  caches in web development.<br>
                </p>
              </div>
            </blockquote>
          </div>
        </div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">Is there already support for atomic writes in
          the standard library?   I am not planning on implementing
          anything new, only exposing existing functionality.   Adding
          atomic operations to the stslib would likely require a pep and
          substantial discussion of API and implementation.   I don&#39;t
          really have the background to do that.</div>
      </div>
    </blockquote>
    <p><br>
    </p>
    <p>So far I didn&#39;t find any of this implemented in the stdlib but
      please correct me if I am wrong.</p>
    <p><br>
    </p>
    <p>As far as I know, one working pattern would be</p>
    <p>1. creating a file or the directory structure using tempfile<br>
      2. then setting permissions from the original directory object<br>
      3. and finally moving it to its final destination (path and name)</p>
    <p>The last part is done atomically at least in Linux (rename) and
      Windows (ReplaceFile).</p>
    <p>Especially setting permission an easy oversight which can cause
      issues e.g. with xsendfile.</p>
    <p><br>
    </p>
    <p>What would be the steps to do get it done?</p></div></blockquote></div><div \
dir="auto">This is outside my area of expertise and is far outside the scope of my \
proposal, so it really needs its own thread.   I think there have periodically been \
requests for atomic file operations on this mailing list, so the first step would be \
to search the mailing list and see what prevented those from going \
anywhere.</div><div class="gmail_quote" dir="auto"><blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>  </div>

</blockquote></div></div>



_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/6Z4CAVIBGQUHMBLEZ3K5GEK64RBO2OYT/
 Code of Conduct: http://python.org/psf/codeofconduct/



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic