





















































What if your Salesforce data was suddenly lost or corrupted? Human errors, accidental deletions, misconfigurations can all contribute to data loss.
1 of 2 SaaS users who did not implement SaaS data protection, experienced data loss or corruption in the last 12 months.
Check out this exclusive webinar where we reveal Rubrik's new integration with Salesforce, designed to tackle this exact issue.
Hi ,
Welcome to this week’s edition of ProgrammingPro!
In today’sExpert Insight, we bring you an excerpt from the recently published book, In-Memory Analytics with Apache Arrow - Second Edition, which shows you how to import Arrow data with Python using the C Data API via the pyarrow
and cffi
modules.
News Highlights: Python 3.13 finally debuts with GIL disabling and JIT compiler; Rust firm at 13th in Tiobe, Mojo enters top 50; Rspack 1.0 is 23x faster than Webpack; and Julia 1.11 introduces a faster, lower-overhead Memory type.
My top 5 picks from today’s learning resources:
But there’s more, so dive right in.
Stay Awesome!
Divya Anne Selvaraj
Editor-in-Chief
PS:The October survey is still live. Do take the opportunity to leave us your feedback, request a learning resource, and earn your one Packt credit for this month.
Print discounts end tomorrow on the 11th of October!
find_first_of
, std::ranges
from C++20, and coroutines from C++23.instanceof
, and switch
statements, the introduction of Markdown documentation comments, and enhancements to concurrency.Here’s an excerpt from “Chapter 4: Crossing the Language Barrier with the Arrow C Data API” in the book, In-Memory Analytics with Apache Arrow - Second Edition by Matthew Topol, published in September 2024.
The common terminology for runtimes providing an interface for calling an API of another runtime or language is an FFI. In Python, we’re going to use a library called cffi
, which is used by the pyarrow
module to implement the C
data API. Make sure that you’re running the script we’re about to write in the same directory as the libsample.so
library file that we created in theprevious exercise:
ffi
library that is part of thepyarrow
module:import pyarrow as pa
from pyarrow.cffi import ffi
cdef
function. Then, we’ll load our shared object librarywithdlopen
:ffi.cdef("void export_int32_data(
struct ArrowArray*);")
lib = ffi.dlopen("./libsample.so")
extern "C"
declarationfrom before.ArrowArray
struct and call the function we exported topopulate it:c_arr = ffi.new("struct ArrowArray*")
c_ptr = int(ffi.cast("uintptr_t", c_arr))
lib.export_int32_data(c_arr)
pyarrow
module to import data. Remember that since we’re passing around pointers, there’s no copying of the data buffers. So, it doesn’t matter whether this array has 1,000 elements or 1 million elements; we’re not copying the data here. Importing the data is just hooking everything up to point to the right areasin memory:arrnew = pa.Array._import_from_c(c_ptr, pa.int32())
# do stuff with the array
del arrnew # will call the release callback
# once it is garbage collected
You can add aprint
statement in there if you like, to confirm that it is actually working as intended. That’s it. The library we created could create that array of data in any way we want, but as long as it properly populates the C struct, we’re able to pass the data around in the Arrow format without having tocopy it.
What if we wanted to work in the other direction? We can read in our data with Python and then hand it off to something faster for processing, similar to how Spark used JPype to communicate the data from Python to Java without copying. How would we go aboutdoing that?
Memory Analytics with Apache Arrow - Second Editionwas published in September 2024. Packt library subscribers can continue reading the entire book for free or you can buy the bookhere!
That’s all for today.
We have an entire range of newsletters with focused content for tech pros. Subscribe to the ones you find the most usefulhere.
If your company is interested in reaching an audience of developers, software engineers, and tech decision makers, you may want toadvertise with us.