Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Make runnable Examples work #590
This PR works around the issues discussed in #529 by using a temp file, rather than
os.Pipe, when executing examples.
See this comment and the 2 I posted previously. Otherwise this looks good to me.
Thank you @shurcooL. I have squished a number of my commits now as well.
I believe the only outstanding issue you brought up is that of reading the file size to pre-allocate an appropriate buffer. Do you think that's still worth doing? The official ioutils package has some pretty elaborate logic about how it handles that (specifically in that it doesn't trust the reported file size to always be accurate). I suspect there are cases of networked filesystems where the size might be under-reported, especially immediately after having written the file. If you think it's worth optimising that bit of code, I can continue to work on it. But as you mentioned, with our small file sizes (the vast majority only a few dozen bytes, I suspect), it may not be worth it.
No problem. Don't hesitate to squash my commits too, there's no reason not to. This PR will likely be merged as one squashed commit anyway.
As for the read file preallocation issue, I don't think it's worth it. It's fine as is.
At the most, you can do a stat to get the file size and use that to set initial buffer size.
Leaving it as is is fine by me. I commented because I wanted us to be aware and make a conscious decision, that's all.
No problem @flimzy, I'm happy if I can I do something useful and help make progress!
Thanks for the PR! I've rebased it on latest master to avoid conflicts in the generated vfsdata file, and merged as one squashed commit (this PR preserves the development history).