Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 843 Bytes

README.md

File metadata and controls

22 lines (16 loc) · 843 Bytes

Ctypes example: large factorials

This examples calculates approximate factorials of large numbers using pure Python or Python with ctypes.

Features demonstrated:

  • packaging C and Python libraries together
  • compiling with gcc through Pixi tasks
  • conditional Pixi task execution (depends_on)
  • defining tasks with arguments

Output

$ pixi run factorial 12345678 python
2023-11-06@18:49:19.296216|INFO|__main__.<module>:50|calculating approximate factorial of 12345678 using pure Python...
2023-11-06@18:49:23.992089|INFO|__main__.<module>:61|12345678! ≈ 1.457260e82187904

$ pixi run factorial 12345678 ctypes
2023-11-06@18:49:29.404679|INFO|__main__.<module>:53|calculating factorial of 12345678 using ctypes...
2023-11-06@18:49:29.947188|INFO|__main__.<module>:61|12345678! ≈ 1.457260e82187904