Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
2 answers
61 views

Issue regarding overlap of memory allocation for separate dataclasses

I am experimenting with defining dataclasses for containing ctypes objects. I have defined three classes; two of which are used as attributes to the third: @dataclasses.dataclass class Point: x = ...
frank's user avatar
  • 41
0 votes
1 answer
83 views

Why double `ctypes.POINTER` object works for `char***` while triple `ctypes.POINTER` would make more sense?

I have a library my_lib with a C function that takes a char*** parameter, a pointer to an array of char* that is allocated by the function. Here is a minimal reproducible example of such a function: ...
jpo38's user avatar
  • 21.8k
0 votes
3 answers
96 views

Pointer in while loop condition in Python

I need function_B to wait for function_A. The wait_for_action_to_be_done() function does the job but I would like something more convenient with wait_for(action_to_wait). The issue is that, in ...
Frankie's user avatar
  • 195
0 votes
0 answers
50 views

Using complex objects as dictionary keys in Python

So I'm working XML files and am not quite sure if what I'm doing is 'Pythonic' enough. The XML file has tagged text and I want to get all paragraphs that contain countries and rivers. So each ...
Yuirike's user avatar
  • 41
0 votes
5 answers
200 views

How about the recursive code for "Find Zero" I've written?

Here's the problem: Given an array nums, write a function that moves all 0s to the end of the array while maintaining the relative order of the non-zero elements. Please note that the array must be ...
Frederick Griffth's user avatar
0 votes
0 answers
25 views

Error while trying to read value from pointer with pymem

This is my first project where i want to read value from offset in one game but it gives me error: An error occurred: Could not read memory at: 1436923512, length: 4 - GetLastError: 299. import ...
Rymicka 's user avatar
1 vote
2 answers
220 views

ctypes "crashes" while trying to return pointer

I am currently trying to get a pointer element back from .dll library (compiled using cygwin and gcc - Source code is in C). But when executing the C function inside of python. The programm just "...
Till Harpenschlaeger's user avatar
0 votes
1 answer
62 views

Callback in python ctypes

I'm trying to wrap a C library in Python using ctypes. A function call requires a callback function which I implemented using the programming manual.The problem is that I'm unable get the return value ...
SABARI SARAVANAN M's user avatar
0 votes
0 answers
67 views

A property of Python class returns an empty numpy array with pybind11

I adopted a project that was abandoned by it's original creator on GH: pybind11 bindings for whispercpp. I had to update Python version from 3.8 to 3.11.8 in CI and discovered that some of the test ...
WintermuteAI's user avatar
0 votes
2 answers
96 views

Multiprocessing sharing c pointer in Python

I tried implementing tree sitter support in Python using multiprocessing but the Python process is crashing. Further below is a Minimum Reproducible Example. My needs are to be able to send the ...
TRCK's user avatar
  • 213
2 votes
1 answer
87 views

Longest Repeating Substring With Replacement

Working on an online practice problem and ran into an issue that I can't seem to figure out. I am looking to find the longest length of a string of characters whose characters can only be replaced &...
EdAlex's user avatar
  • 45
0 votes
1 answer
104 views

Transfer pointer from dll (c/c++) to python

I have a DLL written in C++ ( it can be rewritten in C ) and python code where I import the DLL with cdll.LoadLibrary(). Then I specify a function from DLL and it's agrument types. Then I call the ...
ONamaeWa's user avatar
0 votes
1 answer
34 views

How come original Head of the linked list changes while traversing over it in Python? Am I doing anything wrong?

In the below code, I'm not changing the value of Head still why am I not able to retain the value of Head?The input is a LinkedList: [5, 4, 2, 1] class Solution: def pairSum(self, head: Optional[...
Utkirna Shinde's user avatar
0 votes
1 answer
122 views

Issue with converting C pointers to numpy arrays in Python

I'm trying to utilize a C library using ctypes in Python. The C library provides a subroutine that returns two arrays via pointers: one for integer data and one for float data. Here's a simplified ...
Michael Leanza's user avatar
0 votes
1 answer
61 views

Python integer saved by reference instead of value in an iterable

I have a simple for loop with a count variable that gets saved into a dictionary as part of a string. def chunk_page(page): pages = [] chunks = chunk_string(page['content'], 500, 40) ints =...
Nikita Kholodnyi's user avatar

15 30 50 per page
1
2 3 4 5
45