If you used Rcpp back in the R days, this will feel familiar. I vibe-coded something over the weekend that does the same thing for Python: write C++ inline, call it like a normal function, get results back as numpy arrays. No build system, no separate files, no compilation step. ``` fn = cppFunction(''' std::vector<double> simulate(int n, double mu) { ... } ''') fn(10000, 2.5) ``` Projects like pybind11 and Cython are better for production C++ projects, but this is for when you just need one fast function right next to your Python code. The code compiles on the first call and is cached forever after. Armadillo works out of the box if you have it installed. https://lnkd.in/gt6YQENq
Rcpp-like C++ inline in Python with cppFunction
More Relevant Posts
-
I’ve been using Jupyter notebooks for years, but they tend to get messy once they stop being "temporary". I recently tried marimo, and it feels like a different approach: • notebooks as plain Python files • dependency-based execution (no more weird states) • much cleaner to keep in git What I like most is that it sits somewhere between a notebook and a small app. I also show a real example: using it to recover deleted S3 files. 👉 https://lnkd.in/d_YdRCbd
To view or add a comment, sign in
-
🎉 LaTeX expressions written easily from Python using Latexify library. pip install latexify_py Decorators: - @latexify.expression - @latexify.algorithmic 🍀 Check out Khuyen Tran’s blog post on how to write LaTeX using Latexify, Sympy and regular IPython: https://lnkd.in/gCtsnSDS #bookmark #python #latex #pylib #latexify #tipsandtricks
Have you ever needed to add a math description for your Python function but found it time-consuming? Non-programmers cannot easily read Python logic. However, manually converting it to LaTeX is slow and quickly becomes outdated as the code changes. latexify_py solves this with a single decorator, generating LaTeX directly from your function so the math stays readable and always in sync with the code. Key capabilities: • Three decorators for different outputs: expressions, full equations, or pseudocode • Displays rendered LaTeX directly in Jupyter cells • Functions still work normally when called Plus, latexify_py is open source! Install it with "pip install latexify-py". 🚀 Article on 3 tools that convert Python code to LaTeX: https://bit.ly/4dS4gOB ☕️ Run this code: https://bit.ly/4bW2ycE #Python #LaTeX #DataScience
To view or add a comment, sign in
-
-
🚀 Python 3.13+ is a game-changer: Free-threading (no-GIL mode) and experimental JIT boost multithreaded code by 2-5x! Speed gains are real for CPU-heavy tasks. Tested a simple parallel sum script—3x faster than 3.12. Python 3.15 stabilizes JIT fully. Here’s the snippet: # Run with: python3.13 -X free-threading import threading def compute(n): return sum(i*i for i in range(n)) threads = [threading.Thread(target=compute, args=(10**7,)) for _ in range(4)] for t in threads: t.start() for t in threads: t.join() print("Done!") Who’s upgraded? Share your benchmarks below! 👇 #Python #Python313 #Programming
To view or add a comment, sign in
-
-
I’ve been spending my recent free time in building an Event-Driven Backtesting Engine from scratch for Options. Backtesting complex option strategies requires processing massive amounts of market data, calculating Greeks, and tracking portfolio metrics simultaneously. To handle this without latency bottlenecks, I decided to architect the entire core engine in C++. for now I have mostly tried to make it very flexible like modular commission and slippage and ability to write custom strategies instead of editing the core engine itself I completely decoupled most of the core things so The entire C++ backend is compiled as a standalone library. I am also trying to Integrate a python bridge using pybind11 exposing this compiled library directly to Python. The goal for this is to make the engine to do all the computation in the background, allowing anyone to write, test, and plug in custom strategies dynamically using simple Python scripts without ever needing to modify the core engine files. Getting the C++ event loop to work good with Python scripting is proving to be a little complicated right now! I'll be pushing a final README and some sample strategies once I get the bindings fully stabilized. You guys can check out the code here : https://lnkd.in/gRSgd4gs #quantfinance #cpp #python #algorithmictrading #options #pybind11 #derivatives
To view or add a comment, sign in
-
-
Today’s Python lesson was a quiet reminder that time is one of the most useful things code can help us handle. 🐍 Day 16 of my #30DaysOfPython journey was all about date and time. Python’s date and time module helps us work with: 1. current date and time 2. formatted date strings 3. converting strings into datetime objects 4. time objects 5. time differences and time spans A few things I explored today: 1. dir() and help() to check what a module offers 2. datetime.now() for current date, time, and timestamp 3. strftime() for formatting dates and time 4. strptime() for converting string dates into datetime objects 5. date() to get only day, month, and year 6. subtraction to find the difference between two time points 7. timedelta() to work with time intervals What stood out to me today was how Python does not just store time — it helps you shape it, compare it, and format it in ways that actually make sense for real projects. One more day, one more topic, one more layer of Python making everyday things easier to manage. Github Link - https://lnkd.in/gMy-QseU #Python #LearnPython #CodingJourney #30DaysOfPython #Programming #DeveloperJourney
To view or add a comment, sign in
-
Today’s Python topic felt like the point where code stops being one-time work and starts becoming reusable. 🐍 Day 11 of my #30DaysOfPython journey was all about the basics of function, and this one was a big reminder that good code is not just about writing more — it is about writing smarter. A function is a reusable block of code designed to do a specific task, and in Python, we define it using the def keyword. Today I explored: 1. How functions are created and called 2. How return sends values back from a function and return None when nothing is returned 3. Passing parameters and arguments 4. Passing arguments using key-value style 5. Default parameters 6. Arbitrary arguments with *args 7. Arbitrary named arguments with **kwargs What stood out to me today was how functions make code feel organized, reusable, and much easier to scale. Instead of repeating the same logic again and again, you write it once and use it wherever needed. One more day, one more topic, one more step toward writing code that is cleaner, smarter, and actually built to last. Github Link - https://lnkd.in/gUhhaW_y #Python #LearnPython #CodingJourney #30DaysOfPython #Programming #DeveloperJourney
To view or add a comment, sign in
-
I already had a uv-first setup for Claude Code and Codex. Now I added the Cursor version too. The goal is simple: if a Python project already uses uv, the agent should stay inside that workflow instead of drifting back to pip install, raw python, or manual dependency edits. It sounds like a small detail, but if you use coding agents regularly, these small inconsistencies create a lot of avoidable friction. I wrote a short post about how I extended the same approach to Cursor and kept the workflow consistent across tools: https://lnkd.in/dMZ429Ty
To view or add a comment, sign in
-
-
🚨 This behavior of Python might look like a BUG… but it isn’t actually. a = 10 b = 10 print(id(a)) print(id(b)) 👉 Same memory location 😲 “Why do we have two variables pointing to the same memory location?!” Here comes the second one and things get interesting 👇 a = [1, 2, 3] b = a b.append(4) print(a) # [1, 2, 3, 4] 🔥 👉 Hmmm… why did ‘a’ change?! 💡 Explanation: ⭐ id() returns the identity of an object ⭐ Python reuses memory locations for immutable values ⭐ For mutable objects however, there is no copying, just pointers! ⚠️ The misconception: Most people believe ‘=’ copies objects in variables. 👉 Nope! ✅ Solution: b = a.copy() Now the two variables are separate ✅ 🔥 Consequence: It can seriously mess up your program’s logic! Ever got caught by such a ghost bug in Python? 👇 #CodeWithSujith #Python #Programming #Coding #PythonTricks #LearnPython #PythonBeginner #100DaysOfCode #DeveloperJourney
To view or add a comment, sign in
-
-
Today’s Python lesson felt like the moment code stopped being just instructions and started feeling reusable, flexible, and kind of smart. 🐍 Day 14 of my #30DaysOfPython journey was all about higher order functions, and this one made Python feel a lot more powerful. In Python, functions are first-class citizens, which means they can: 1. take other functions as parameters 2. return functions as results 3. be modified 4. be assigned to variables Today I also explored: 1. Functions as parameters 2. Functions as return values 3. Closures — where an inner function can use the outer function’s scope 4. Decorators — a clean way to add extra behavior without changing the original function 5. Built-in higher order functions like: i. map() → transforms items ii. filter() → keeps only matching items iii. reduce() → combines items into one value What stood out to me today was how Python lets functions do more than one job. They are not just blocks of code anymore — they can actually shape how other code behaves. One more day, one more topic, one more step toward thinking in cleaner, more reusable logic. Which one feels the most interesting to you right now: map(), filter(), reduce(), or decorators? Github Link - https://lnkd.in/gc-mj8Qi #Python #LearnPython #CodingJourney #30DaysOfPython #Programming #DeveloperJourney
To view or add a comment, sign in
-
Every analyst I know learned Python the hard way — by Googling the same things over and over. This 3-page cheatsheet covers everything from DataFrames to GroupBy to the exact workflow I follow on every project. No code overwhelm. Just concepts, clearly explained. Save this. You'll come back to it.
To view or add a comment, sign in
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development