Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Persistent File System with OPFS#2314

Ridensium started this conversation inProposals
Mar 11, 2025· 2 comments· 4 replies
Discussion options

As pyscript already has fs module it will be great to have official way to use the Origin Private File System in the browser. It is much faster for big files as well more secure than indexedDB api, and can be made to work on all browsers including mobile devices.

You must be logged in to vote

Replies: 2 comments 4 replies

Comment options

That API is basically designed to work only in a Dynamic Worker (not Shared, not Service, just Worker) due its ability to block behind the scene while locking the OS file system.

None of our current offer/APIs uses the leading tab/main pattern as that would require a lot of orchestrationbut it's not excluded we might just do that in the near future ... meanwhile, all our APIs to deal with the OS native FS or the browser IndexedDB feature should "just work", so I wonder what is it exactly that you are after, as that OPFS discussion is something I am aware of due SQLite on browsers integration, but use cases around it are kinda obscure to me ... so, do yu mind expanding on that?

You must be logged in to vote
0 replies
Comment options

OK, so the native FS is supported only by Chromium browser and even not available on Android so no so usable up today for what i am doing. IndexedDB is so slow on big "files" on my tests a fiction novel text size on medium android device gets lots of seconds to be saved, reads are fine but not sure if gets lots of "files" what will be. So for persistence and better performance as well better device/browser support seems OPFS is kinda good solution. So because I need some solution aniway, made one till there are official one, no pretending to be good :) as i am not professional developer:
https://github.com/Ridensium/persipy - the module
https://rdsm.pyscriptapps.com/persipy/latest/ - the example

You must be logged in to vote
4 replies
@WebReflection
Comment options

I am not sure I am following but you are using my implementation ofmounteNativeFS which isnot based onOPFS:

awaitinterpreter.mountNativeFS(mount_path,dirHandle)#nativefs

so it looks like you just created some sort of path utility based on what we offer already, am I correct? If that's the demo/case, that's cool and we should think about integrating it in ourfs API, I suppose, but we need to discuss if that's what we want too.

On the other hand, withpyscript.fs you can mount already a directory, crawl it, read and safe stuff in it, so what is persipy doing better, if I might ask? 🤔

@Ridensium
Comment options

First want to thank to you and all the contributors of pyscript for the great job. You sure know whats the best to put efforts on and shoudn't solve some isolated cased indeed. The latter may evolve on top of pyscript. Thepyscript.fs api works great for the scope it was made for,persipy does nothing better. The goal is another scope (all the browsers incl. mobile as well persistence for the app assets) rather duplicate a feature. The_pyscript.interpreter together withmounteNativeFS helps a lot to made it easier, yet sharing code which uses internal apis - i am starting to consider as not a good and sustainable practice at all. Will reshape it to use the official ones only in to be tweaking friendly. Don't wanna mess with pyscript's roadmap, just sharing what i am doing to solve my case. Maybe it's a good idea to try that pyscript fun_show_and_tell calls 🤔

@WebReflection
Comment options

it's all good ... my question was genuine though: what is it that your project is doing? The moment you usemountNativeFS all files in there will be loaded into memory (Emscripten FileSystem API) so that Python can access those files from memory ...OPFS goal, specially the synchronous one, is to avoid loading everything in memory but right now there's no bridge between Pyodide or MicroPython WASM runtime VS synchronous persistent file system access ... unless you solved that, but from a quick look, that doesn't seem to be the case ... or is it? If not, I think you'd be good withpyscript.fs features and maybe help us shaping anything better we could provide in there, so that we can refine and improve out of the community, which would be awesome!

would you agree? anything I've written that is off or requires more personal investigation?

@Ridensium
Comment options

Totally agree. I am not an profesional dev, and just trying to solve my case and share with the community if it may benefit. With sure i am not playing with WASM so you guess right. The project shoud work well on e-ink devices too, most of which are pretty weak. For comparison something takes 0.01s on iphone15 there it may take a minute. Pyodide for example loads for 10+ minutes if you are lucky to load at all. The data is from one page text up to full fledged novel (mb more or less). Thats why performance and caching is so paramount and on top of that to be as much hard for bots or automated systems to grab some data. This weekend will finish a version of persify in a waymountNativeFS to be optional, i have no problem to use it in a wayopfs.read/write(..) w/o real mounting which will eat some precious memory for those paperish screen devices (thanks for the reminder). Will add some docs too.

Offtopic maybe - please check themicropython performace on reading files bigger than 1+Mb in the vfs. Idk why but whilepyodide is just fine, the mpy seems struggle even on apple M4.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
2 participants
@Ridensium@WebReflection

[8]ページ先頭

©2009-2025 Movatter.jp