Show HN: ApplePy – Embed and Call Swift from Python (Like PyO3, but for Swift)

github.com
sheepscreek
8 hours ago
2points
2 comments

Comments

sheepscreek8 hours ago
I built ApplePy because I couldn't find anything that let you use Swift from Python -- only the reverse (embedding Python inside Swift). After experimenting with a few approaches, I got inspired by PyO3's model and decided to build something analogous for the Swift ecosystem.

Why Swift as a native extension language? A few things people underestimate:

- Swift doesn't have a garbage collector. Like Rust, it uses automatic reference counting (implicit by default) with copy-on-write semantics for safe concurrency you get most of Rust's memory safety guarantees with a much lighter syntax.

- Performance lands around 80% of Rust out of the box, with compiler hints available to close the gap further if you need to tune hot paths.

- Swift 6.3 ships native C++ interop, and the same codebase compiles to iOS, Android, Windows, Linux, and macOS.

For Python developers who want native-speed extensions without writing C or wrestling with Rust's learning curve, Swift is a genuinely underappreciated option. ApplePy tries to make that path practical.

The project is early - feedback and contributions very welcome.

sjdv19824 hours ago
Could you apply this to speed up cherrypy?
reducirimagen6 hours ago
[dead]