Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"From there to here, from here to there, funny things are everywhere." -- Dr. Seuss


devel / comp.lang.python / Re: Data unchanged when passing data to Python in multiprocessing shared memory

SubjectAuthor
* Re: Data unchanged when passing data to Python in multiprocessingJen Kris
+- Re: Data unchanged when passing data to Python in multiprocessingAvi Gross
+- Re: Data unchanged when passing data to Python in multiprocessingJen Kris
+- Re: Data unchanged when passing data to Python in multiprocessingJen Kris
+- Re: Data unchanged when passing data to Python in multiprocessingAvi Gross
`- Re: Data unchanged when passing data to Python in multiprocessingChris Angelico

1
Re: Data unchanged when passing data to Python in multiprocessing shared memory

<mailman.11.1643758824.2976.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21256&group=comp.lang.python#21256

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: jenkris@tutanota.com (Jen Kris)
Newsgroups: comp.lang.python
Subject: Re: Data unchanged when passing data to Python in multiprocessing
shared memory
Date: Wed, 2 Feb 2022 00:40:22 +0100 (CET)
Lines: 99
Message-ID: <mailman.11.1643758824.2976.python-list@python.org>
References: <Muqv9er--3-2@tutanota.com>
<35BA674C-1AAF-43B3-9203-BBF7472E6AE4@barrys-emacs.org>
<MureHAB----2@tutanota.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de ABocw9ARWiCq+EzZ1MAX1A/dWHrDsAcDPKKNNBTnPD6w==
Return-Path: <jenkris@tutanota.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=tutanota.com header.i=@tutanota.com header.b=xaq6IRBO;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python?': 0.03; 'knows':
0.04; 'python:': 0.05; 'subject:when': 0.07; 'python.': 0.08;
'cc:addr:python-list': 0.09; 'know.\xc2\xa0': 0.09; 'memory.':
0.09; 'theory': 0.09; 'subject:Python': 0.12; 'url:mailman': 0.15;
'memory': 0.15; '2022,': 0.16; 'barry': 0.16; 'cc:name:python
list': 0.16; 'char': 0.16; 'integer': 0.16; 'language?': 0.16;
'pipe': 0.16; 'protocol.': 0.16; 'subject:shared': 0.16;
'subject:skip:m 10': 0.16; 'sync': 0.16; 'unsigned': 0.16;
'want,': 0.16; 'wrote:': 0.16; 'problem': 0.16; 'python': 0.16;
'feb': 0.17; "can't": 0.17; 'uses': 0.19; 'cc:addr:python.org':
0.20; 'language': 0.21; 'maybe': 0.22; 'code': 0.23;
'received:de': 0.23; '(and': 0.25; 'url-ip:188.166.95.178/32':
0.25; 'url-ip:188.166.95/24': 0.25; 'url:listinfo': 0.25;
'cc:2**0': 0.25; 'url-ip:188.166/16': 0.25; 'anyone': 0.25;
'binary': 0.26; 'email addr:python.org&gt;': 0.28; 'url-ip:188/8':
0.31; 'program': 0.31; 'question': 0.32; 'attaching': 0.32; 'do.':
0.32; 'python-list': 0.32; 'received:192.168.1': 0.32; 'but':
0.32; 'header:In-Reply-To:1': 0.34; 'following': 0.35; 'thanks,':
0.36; 'people': 0.36; 'using': 0.37; "it's": 0.37; 'this.': 0.37;
'received:192.168': 0.37; 'read': 0.38; 'thanks': 0.38; 'text':
0.39; 'list': 0.39; 'use': 0.39; 'shared': 0.39; 'both': 0.40;
'four': 0.60; 'seen': 0.62; 'skip:i 20': 0.62; 'send': 0.63;
'skip:m 20': 0.63; 'between': 0.63; 'pass': 0.64; 'verify': 0.64;
'clear': 0.64; 'lock': 0.64; 'your': 0.64; '&amp;': 0.65; 'let':
0.66; 'back': 0.67; 'exactly': 0.68; 'know.': 0.68; 'refers':
0.69; 'subject:Data': 0.71; 'little': 0.73; 'points': 0.84; 'email
name:&lt;python-list': 0.84; 'naturally': 0.84; 'pointer': 0.84;
'subject: \n ': 0.84; 'subject:memory': 0.84; 'want.': 0.84
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1643758822;
s=s1; d=tutanota.com;
h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender;
bh=Yu7mUbBeEHmpbZriPL5ccN/5j22koc3ELPWsNAkxjCo=;
b=xaq6IRBOPfFQmwJzzilgtjSM+bj4xp0AoDobXitEEa0tJCGVS4KHNtSgKoMN5Bg6
zcMOXi81MnC/D5b+TRsZuRtJgNqdrGUMTvG8FZydh7/m5CgeaDq/PSMI25Am7rSY5TB
HHRehgxiU7PhtDVBx6S3vPux6HR7vL1CvboMRd9Fft75NumQ+pflxeWKy5x/gS1lN9F
yPskG5hcROoTS7vNKENEFTDSB3ebZBCpKco3ojoAXi0cQJojRv1YmufzAG88fU1MaZk
uy5ZkQ4AHicKS2J5JrwXQub6SDHOM/oCzjk6kwE6DspIm3ed9WjKoB4ZVyjM95nxWG2
2kIQu3YUIw==
In-Reply-To: <35BA674C-1AAF-43B3-9203-BBF7472E6AE4@barrys-emacs.org>
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <MureHAB----2@tutanota.com>
X-Mailman-Original-References: <Muqv9er--3-2@tutanota.com>
<35BA674C-1AAF-43B3-9203-BBF7472E6AE4@barrys-emacs.org>
 by: Jen Kris - Tue, 1 Feb 2022 23:40 UTC

Barry, thanks for your reply. 

On the theory that it is not yet possible to pass data from a non-Python language to Python with multiprocessing.shared_memory, I bypassed the problem by attaching 4 bytes to my FIFO pipe message from NASM to Python:

byte_val = v[10:14]

where v is the message read from the FIFO.  Then:

breakup = int.from_bytes(byte_val, "big")
print("this is breakup " + str(breakup))

Python prints:  this is breakup 32894

Note that I had to switch from little endian to big endian.  Python is little endian by default, but in this case it's big endian. 

However, if anyone on this list knows how to pass data from a non-Python language to Python in multiprocessing.shared_memory please let me (and the list) know. 

Thanks. 

Feb 1, 2022, 14:20 by barry@barrys-emacs.org:

>
>
>> On 1 Feb 2022, at 20:26, Jen Kris via Python-list <python-list@python.org> wrote:
>>
>> I am using multiprocesssing.shared_memory to pass data between NASM and Python. The shared memory is created in NASM before Python is called. Python connects to the shm: shm_00 = shared_memory.SharedMemory(name='shm_object_00',create=False).
>>
>> I have used shared memory at other points in this project to pass text data from Python back to NASM with no problems. But now this time I need to pass a 32-bit integer (specifically 32,894) from NASM to Python.
>>
>> First I convert the integer to bytes in a C program linked into NASM:
>>
>> unsigned char bytes[4]
>> unsigned long int_to_convert = 32894;
>>
>> bytes[0] = (int_to_convert >> 24) & 0xFF;
>> bytes[1] = (int_to_convert >> 16) & 0xFF;
>> bytes[2] = (int_to_convert >> 8) & 0xFF;
>> bytes[3] = int_to_convert & 0xFF;
>> memcpy(outbuf, bytes, 4);
>>
>> where outbuf is a pointer to the shared memory. On return from C to NASM, I verify that the first four bytes of the shared memory contain what I want, and they are 0, 0, -128, 126 which is binary 00000000 00000000 10000000 01111110, and that's correct (32,894).
>>
>> Next I send a message to Python through a FIFO to read the data from shared memory. Python uses the following code to read the first four bytes of the shared memory:
>>
>> byte_val = shm_00.buf[:4]
>> print(shm_00.buf[0])
>> print(shm_00.buf[1])
>> print(shm_00.buf[2])
>> print(shm_00.buf[3])
>>
>> But the bytes show as 40 39 96 96, which is exactly what the first four bytes of this shared memory contained before I called C to overwrite them with the bytes 0, 0, -128, 126. So Python does not see the updated bytes, and naturally int.from_bytes(byte_val, "little") does not return the result I want.
>>
>> I know that Python refers to shm00.buf, using the buffer protocol. Is that the reason that Python can't see the data that has been updated by another language?
>>
>> So my question is, how can I alter the data in shared memory in a non-Python language to pass back to Python?
>>
>
> Maybe you need to use a memory barrier to force the data to be seen by another cpu?
> Maybe use shm lock operation to sync both sides?
> Googling I see people talking about using stdatomic.h for this.
>
> But I am far from clear what you would need to do.
>
> Barry
>
>>
>> Thanks,
>>
>> Jen
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>

Re: Data unchanged when passing data to Python in multiprocessing shared memory

<mailman.17.1643825772.2976.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21263&group=comp.lang.python#21263

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: avigross@verizon.net (Avi Gross)
Newsgroups: comp.lang.python
Subject: Re: Data unchanged when passing data to Python in multiprocessing
shared memory
Date: Wed, 2 Feb 2022 18:16:07 +0000 (UTC)
Lines: 97
Message-ID: <mailman.17.1643825772.2976.python-list@python.org>
References: <Muqv9er--3-2@tutanota.com>
<35BA674C-1AAF-43B3-9203-BBF7472E6AE4@barrys-emacs.org>
<MureHAB----2@tutanota.com>
<mailman.11.1643758824.2976.python-list@python.org>
<s44kvg91u4dbvq1nh2uoaj9gd7o20d5fka@4ax.com>
<706734682.2805722.1643825767629@mail.yahoo.com>
Reply-To: Avi Gross <avigross@verizon.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de TbeTKPSTPhiiiykNUQG5sghz9tcp6fFWUElr+Q5x0teg==
Return-Path: <avigross@verizon.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=verizon.net header.i=@verizon.net header.b=jNqZ/dfx;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.006
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'knows': 0.04; '2022':
0.05; 'string': 0.07; 'subject:when': 0.07; 'byte': 0.09; 'flags':
0.09; 'know.\xc2\xa0': 0.09; 'mechanism': 0.09; 'module.': 0.09;
'obviously,': 0.09; 'order,': 0.09; 'string,': 0.09; 'trivial':
0.09; 'subject:Python': 0.12; 'url:mailman': 0.15; 'memory': 0.15;
'(windows': 0.16; 'bits': 0.16; 'heavily': 0.16; 'ideal.': 0.16;
'incompatible': 0.16; 'integer': 0.16; 'something?': 0.16;
'subject:shared': 0.16; 'subject:skip:m 10': 0.16; 'python': 0.16;
'feb': 0.17; "can't": 0.17; 'to:addr:python-list': 0.20;
'language': 0.21; 'lines': 0.23; 'run': 0.23; 'to:name:python-
list@python.org': 0.24; '(and': 0.25; 'anything': 0.25; 'skip:-
10': 0.25; 'url-ip:188.166.95.178/32': 0.25; 'url-
ip:188.166.95/24': 0.25; 'url:listinfo': 0.25; 'url-
ip:188.166/16': 0.25; 'anyone': 0.25; 'done': 0.28; 'url-
ip:188/8': 0.31; 'think': 0.32; 'but': 0.32; "i'm": 0.33; 'same':
0.34; 'header:In-Reply-To:1': 0.34; 'trying': 0.35; 'functions':
0.36; 'missing': 0.37; 'necessarily': 0.37; "it's": 0.37; 'way':
0.38; 'read': 0.38; 'list': 0.39; 'shared': 0.39; 'wed,': 0.39;
'support.': 0.40; 'both': 0.40; 'want': 0.40; 'from:': 0.62;
'to:': 0.62; 'seen': 0.62; 'skip:i 20': 0.62; 'reasonable': 0.62;
'send': 0.63; 'skip:m 20': 0.63; 'pass': 0.64; 're:': 0.64;
'your': 0.64; 'look': 0.65; 'let': 0.66; 'back': 0.67; 'right':
0.68; 'end,': 0.69; 'following:': 0.69; 'subject:Data': 0.71;
'little': 0.73; 'sent:': 0.78; 'header:Reply-To:1': 0.79;
'"1234"': 0.84; 'converts': 0.84; 'subject: \n ': 0.84;
'subject:memory': 0.84; 'unchanged': 0.84; 'url-ip:146/8': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048;
t=1643825768; bh=ycZSjcBwWGvRau1AJ5yOwh6hvDKFfFm8sGhKYg3X8+Q=;
h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject:Reply-To;
b=jNqZ/dfxkO04mkvzt84rEafI8SiDdmYGe/rU5TMyJL5FXG6CLdPFq6OOmldjCpWpSiEp7IHBL0xtquwbmBb38nLeULPWPngjMdUhDlJ6cYxXyPQQATg97vug1b4wd60ucGiDzkih6GAsE1Luy1AGWZXmPmyqGQOen2EpcGorQSyVdRNV6lE6DTsjheWSg8f36xkk0kjx3pEVQnAddOip0VvOPtfDU6wVmbtpGHH8SBcOU7Fi1J/7I1DP9+zcjs2fXTZotBYjkmK/0KplS1hSn17DomMgvUoVzFAhbZcLDsA1VfCHEyCFZCH39+6yKYc3rj83h8yLjVhJX4S+OHAtfg==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
t=1643825768; bh=+BKC+g+bppDsvJa7sTVqi1qh79fUtj2jn0INUSaEgm/=;
h=X-Sonic-MF:Date:From:To:Subject:From:Subject;
b=rFYAkwBjN1bnwM5pdBAb9g9H0JIWKnhueaiWU8AiwpCcbw24gKUiIkeIXRWR1p2gr0qnJXby+jjZcu7VVV4Qfhi2a1JuGX3D9poMv2jPBSNhryhWuQOFZoKXZLZ6u6dZR2mOJkSJYxYlICTy0mJjiYAoGT7tw0zpXMs3SB8l/bjoNMjkeRCrRjVTAuEumw0eH6bDgRtfy9BJ0agwKGg/tcXRDpjjZz+W+aZwTTqaUQXs1rGiQEEHrh2wFJL0C2pDr/U2fVm69GTbJb5zKxz20N44OXsLFA6DMEjunL4WaIokmK6t5rdiarLl4JN6rSA+B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dGA21jV_X_iUpq2Ddqh3oCF6
SJu6gfl6.Lwt_dWAjMLvArc4rKPo.EbOy.a3lPbK618556yZ8JX0N2KsZbc_B5fqk.3IwUnSxNnH
KxDRnGGCl3OXAReLTfnux_yvaFK0Cn7IWBrWk1xC4GjaEdUDq4XZig.Ok4e1_.Hoz2O3.bVGmHzq
a8MDHDkMRrqAidVVBWe4X4WKbcNcypSdS
X-Sonic-MF: <avigross@verizon.net>
In-Reply-To: <s44kvg91u4dbvq1nh2uoaj9gd7o20d5fka@4ax.com>
X-Mailer: WebService/1.1.19615 aolwebmail
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <706734682.2805722.1643825767629@mail.yahoo.com>
X-Mailman-Original-References: <Muqv9er--3-2@tutanota.com>
<35BA674C-1AAF-43B3-9203-BBF7472E6AE4@barrys-emacs.org>
<MureHAB----2@tutanota.com>
<mailman.11.1643758824.2976.python-list@python.org>
<s44kvg91u4dbvq1nh2uoaj9gd7o20d5fka@4ax.com>
 by: Avi Gross - Wed, 2 Feb 2022 18:16 UTC

I applaud trying to find the right solution but wonder if a more trivial solution is even being considered. It ignores big and little endians and just converts your data into another form and back.

If all you want to do is send an integer that fit in 32 bits or 64 bits, why not convert it to a character string in a form that both machines will see the same way and when read back, convert it back to an integer?

As long as both side see the same string, this can be done in reasonable time and portably.

Or am I missing something? Is "1234" not necessarily seen in the same order, or "1.234e3" or whatever?

Obviously, if the mechanism is heavily used and multiple sides keep reading and even writing the same memory location, this is not ideal. But having different incompatible processors looking at the same memory is also not.

-----Original Message-----
From: Dennis Lee Bieber <wlfraed@ix.netcom.com>
To: python-list@python.org
Sent: Wed, Feb 2, 2022 12:30 am
Subject: Re: Data unchanged when passing data to Python in multiprocessing shared memory

On Wed, 2 Feb 2022 00:40:22 +0100 (CET), Jen Kris <jenkris@tutanota.com>

declaimed the following:

>

> breakup = int.from_bytes(byte_val, "big")

>print("this is breakup " + str(breakup))

>

>Python prints:  this is breakup 32894

>

>Note that I had to switch from little endian to big endian.  Python is little endian by default, but in this case it's big endian. 

>

    Look at the struct module. I'm pretty certain it has flags for big or

little end, or system native (that, or run your integers through the

various "network byte order" functions that I think C and Python both

support.

https://www.gta.ufrj.br/ensino/eel878/sockets/htonsman.html

>However, if anyone on this list knows how to pass data from a non-Python language to Python in multiprocessing.shared_memory please let me (and the list) know. 

    <pondering>MMU cache lines not writing through to RAM? Can't find

anything on Google to force a cache flush</pondering> Can you test on a

different OS? (Windows vs Linux)

--

    Wulfraed                Dennis Lee Bieber        AF6VN

    wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

--

https://mail.python.org/mailman/listinfo/python-list

Re: Data unchanged when passing data to Python in multiprocessing shared memory

<mailman.18.1643825781.2976.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21264&group=comp.lang.python#21264

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: jenkris@tutanota.com (Jen Kris)
Newsgroups: comp.lang.python
Subject: Re: Data unchanged when passing data to Python in multiprocessing
shared memory
Date: Wed, 2 Feb 2022 19:16:19 +0100 (CET)
Lines: 52
Message-ID: <mailman.18.1643825781.2976.python-list@python.org>
References: <Muqv9er--3-2@tutanota.com>
<35BA674C-1AAF-43B3-9203-BBF7472E6AE4@barrys-emacs.org>
<MureHAB----2@tutanota.com>
<mailman.11.1643758824.2976.python-list@python.org>
<s44kvg91u4dbvq1nh2uoaj9gd7o20d5fka@4ax.com>
<MuvdgZg--3-2@tutanota.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de P+Xl+LBzVl1gwqaS2e2RUAI+kowe3jnnlSDVWaWMzRLg==
Return-Path: <jenkris@tutanota.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=tutanota.com header.i=@tutanota.com header.b=XrOSvDfS;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.009
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'knows': 0.04; '2022':
0.05; 'subject:when': 0.07; 'byte': 0.09; 'cc:addr:python-list':
0.09; 'flags': 0.09; 'know.\xc2\xa0': 0.09; 'module.': 0.09;
'subject:Python': 0.12; 'url:mailman': 0.15; '(windows': 0.16;
'2022,': 0.16; 'cc:name:python list': 0.16; 'specified,': 0.16;
'subject:shared': 0.16; 'subject:skip:m 10': 0.16; 'python': 0.16;
'feb': 0.17; "can't": 0.17; 'cc:addr:python.org': 0.20;
'language': 0.21; 'lines': 0.23; 'run': 0.23; 'received:de': 0.23;
'(and': 0.25; 'anything': 0.25; 'url-ip:188.166.95.178/32': 0.25;
'url-ip:188.166.95/24': 0.25; 'url:listinfo': 0.25; 'cc:2**0':
0.25; 'url-ip:188.166/16': 0.25; 'anyone': 0.25; 'module': 0.31;
'url-ip:188/8': 0.31; 'think': 0.32; 'zero': 0.32;
'received:192.168.1': 0.32; 'but': 0.32; "i'm": 0.33; 'header:In-
Reply-To:1': 0.34; 'functions': 0.36; "it's": 0.37;
'received:192.168': 0.37; 'list': 0.39; 'wed,': 0.39; 'support.':
0.40; 'both': 0.40; 'four': 0.60; 'skip:i 20': 0.62; 'skip:m 20':
0.63; 'pass': 0.64; 'clear': 0.64; 'your': 0.64; 'look': 0.65;
'let': 0.66; 'know.': 0.68; 'end,': 0.69; 'following:': 0.69;
'subject:Data': 0.71; 'little': 0.73; 'skip:f 20': 0.75; 'subject:
\n ': 0.84; 'subject:memory': 0.84; 'url-ip:146/8': 0.84
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1643825779;
s=s1; d=tutanota.com;
h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender;
bh=H4IBCMgtEupDtLgQskJDeGG/t1eBOTmmuEPg+h80NBk=;
b=XrOSvDfS3VIFt6a9QNLMuXybLjjxpzkq6W2SSLSzbKybuKZYQTivJIiIoHZAlLqc
XUFS+JdiEtgxNuCk2J0TjgXB2Xe6ExZxsrsPatq7F7sGk3Oz3ojp0aBpc9tbj5lJdRx
1fqTOYnnaFipF/UmTTlFTv1W3vurdp7x5J8t1Ku67p20oZUEcagNLTPMhd1C9IXe8dt
KKtmv+5FqR42O9cvw2o8wbsIoICJf4SmTtMny3jYZ9yOfCS0ZDh/7Aavm5r5jlt0H1G
fi7XpWEUaum+HMMbKU+DJgnzixD9kOWGRT3MicQdTboHABXL9uAhxANY//Ey+VHwgi0
jW59DdoLAQ==
In-Reply-To: <s44kvg91u4dbvq1nh2uoaj9gd7o20d5fka@4ax.com>
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <MuvdgZg--3-2@tutanota.com>
X-Mailman-Original-References: <Muqv9er--3-2@tutanota.com>
<35BA674C-1AAF-43B3-9203-BBF7472E6AE4@barrys-emacs.org>
<MureHAB----2@tutanota.com>
<mailman.11.1643758824.2976.python-list@python.org>
<s44kvg91u4dbvq1nh2uoaj9gd7o20d5fka@4ax.com>
 by: Jen Kris - Wed, 2 Feb 2022 18:16 UTC

It's not clear to me from the struct module whether it can actually auto-detect endianness.  I think it must be specified, just as I had to do with int.from_bytes().  In my case endianness was dictated by how the four bytes were populated, starting with the zero bytes on the left. 

Feb 1, 2022, 21:30 by wlfraed@ix.netcom.com:

> On Wed, 2 Feb 2022 00:40:22 +0100 (CET), Jen Kris <jenkris@tutanota.com>
> declaimed the following:
>
>>
>> breakup = int.from_bytes(byte_val, "big")
>>
> >print("this is breakup " + str(breakup))
>
>>
>>
> >Python prints:  this is breakup 32894
>
>>
>>
> >Note that I had to switch from little endian to big endian.  Python is little endian by default, but in this case it's big endian. 
>
>>
>>
> Look at the struct module. I'm pretty certain it has flags for big or
> little end, or system native (that, or run your integers through the
> various "network byte order" functions that I think C and Python both
> support.
>
> https://www.gta.ufrj.br/ensino/eel878/sockets/htonsman.html
>
>
> >However, if anyone on this list knows how to pass data from a non-Python language to Python in multiprocessing.shared_memory please let me (and the list) know. 
>
> <pondering>MMU cache lines not writing through to RAM? Can't find
> anything on Google to force a cache flush</pondering> Can you test on a
> different OS? (Windows vs Linux)
>
>
>
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Re: Data unchanged when passing data to Python in multiprocessing shared memory

<mailman.19.1643826431.2976.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21265&group=comp.lang.python#21265

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: jenkris@tutanota.com (Jen Kris)
Newsgroups: comp.lang.python
Subject: Re: Data unchanged when passing data to Python in multiprocessing
shared memory
Date: Wed, 2 Feb 2022 19:27:09 +0100 (CET)
Lines: 113
Message-ID: <mailman.19.1643826431.2976.python-list@python.org>
References: <Muqv9er--3-2@tutanota.com>
<35BA674C-1AAF-43B3-9203-BBF7472E6AE4@barrys-emacs.org>
<MureHAB----2@tutanota.com>
<mailman.11.1643758824.2976.python-list@python.org>
<s44kvg91u4dbvq1nh2uoaj9gd7o20d5fka@4ax.com>
<706734682.2805722.1643825767629@mail.yahoo.com>
<MuvgAhH--3-2@tutanota.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de QLZCw0wy2lg3W75Lg3H6QAh6ynG3/NK6cN8aRBmzspsA==
Return-Path: <jenkris@tutanota.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=tutanota.com header.i=@tutanota.com header.b=4bRY22fd;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.008
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'knows': 0.04; '2022':
0.05; 'string': 0.07; 'subject:when': 0.07; 'byte': 0.09; 'cc:addr
:python-list': 0.09; 'flags': 0.09; 'know.\xc2\xa0': 0.09;
'mechanism': 0.09; 'module.': 0.09; 'obviously,': 0.09; 'order,':
0.09; 'string,': 0.09; 'trivial': 0.09; 'subject:Python': 0.12;
'url:mailman': 0.15; 'memory': 0.15; '(windows': 0.16; '2022,':
0.16; 'bits': 0.16; 'email addr:python.org:': 0.16; 'heavily':
0.16; 'ideal.': 0.16; 'incompatible': 0.16; 'integer': 0.16;
'something?': 0.16; 'subject:shared': 0.16; 'subject:skip:m 10':
0.16; 'python': 0.16; 'feb': 0.17; "can't": 0.17;
'cc:addr:python.org': 0.20; 'language': 0.21; 'lines': 0.23;
'run': 0.23; 'received:de': 0.23; '(and': 0.25; 'anything': 0.25;
'skip:- 10': 0.25; 'url-ip:188.166.95.178/32': 0.25; 'url-
ip:188.166.95/24': 0.25; 'url:listinfo': 0.25; 'cc:2**0': 0.25;
'url-ip:188.166/16': 0.25; 'anyone': 0.25; 'done': 0.28; 'url-
ip:188/8': 0.31; 'program': 0.31; 'think': 0.32;
'received:192.168.1': 0.32; 'but': 0.32; "i'm": 0.33; 'same':
0.34; 'work.': 0.34; 'header:In-Reply-To:1': 0.34; 'trying': 0.35;
'functions': 0.36; 'missing': 0.37; 'necessarily': 0.37; "it's":
0.37; 'received:192.168': 0.37; 'way': 0.38; 'read': 0.38; 'list':
0.39; 'shared': 0.39; 'wed,': 0.39; 'support.': 0.40; 'both':
0.40; 'want': 0.40; 'from:': 0.62; 'to:': 0.62; 'seen': 0.62;
'skip:i 20': 0.62; 'reasonable': 0.62; 'send': 0.63; 'skip:m 20':
0.63; 'pass': 0.64; 're:': 0.64; 'your': 0.64; 'look': 0.65;
'let': 0.66; 'back': 0.67; 'right': 0.68; 'know.': 0.68; 'end,':
0.69; 'following:': 0.69; 'showed': 0.69; 'subject:Data': 0.71;
'little': 0.73; 'five': 0.75; 'skip:f 20': 0.75; 'sent:': 0.78;
'"1234"': 0.84; 'converts': 0.84; 'four.': 0.84; 'subject: \n ':
0.84; 'subject:memory': 0.84; 'unchanged': 0.84; 'url-ip:146/8':
0.84; 'work.\xc2\xa0': 0.84
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1643826429;
s=s1; d=tutanota.com;
h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender;
bh=iu3nXTCNtjGMu84E6IkhYxjv8MKYvK+nvKD0n10FZoQ=;
b=4bRY22fdIm/6lsqA2crBj0h5O7duP1UfcjAVHQhp5SwHMrrEr2Xw4uptP6puG+a9
BwPayrsqFoPwb4OD1/lhaqOddKOj1X+JV59GC8jQl4zaePgSvlaSNI+2vD6e0dPLJB8
L2C3ZiYufJHMvF+trumglAcejThBIJYLEEgSPOsjO4tfIGhN+9maTsDh1llYz6MMrIK
NjQyS5dFvfSLuhmxwjV5esC/8D8cJHI6q0+xuSiat/QuZNYXh7eaO2GvcSWIojYW6t/
7LG4YKO39Ope/o+HuAfFa/egDx7USM5lvZIn4TSKw3OqPFzdfoLNzL6PwHFOVP07Q6t
nkZDsqggLA==
In-Reply-To: <706734682.2805722.1643825767629@mail.yahoo.com>
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <MuvgAhH--3-2@tutanota.com>
X-Mailman-Original-References: <Muqv9er--3-2@tutanota.com>
<35BA674C-1AAF-43B3-9203-BBF7472E6AE4@barrys-emacs.org>
<MureHAB----2@tutanota.com>
<mailman.11.1643758824.2976.python-list@python.org>
<s44kvg91u4dbvq1nh2uoaj9gd7o20d5fka@4ax.com>
<706734682.2805722.1643825767629@mail.yahoo.com>
 by: Jen Kris - Wed, 2 Feb 2022 18:27 UTC

An ASCII string will not work.  If you convert 32894 to an ascii string you will have five bytes, but you need four.  In my original post I showed the C program I used to convert any 32-bit number to 4 bytes. 

Feb 2, 2022, 10:16 by python-list@python.org:

> I applaud trying to find the right solution but wonder if a more trivial solution is even being considered. It ignores big and little endians and just converts your data into another form and back.
>
> If all you want to do is send an integer that fit in 32 bits or 64 bits, why not convert it to a character string in a form that both machines will see the same way and when read back, convert it back to an integer?
>
> As long as both side see the same string, this can be done in reasonable time and portably.
>
> Or am I missing something? Is "1234" not necessarily seen in the same order, or "1.234e3" or whatever?
>
> Obviously, if the mechanism is heavily used and multiple sides keep reading and even writing the same memory location, this is not ideal. But having different incompatible processors looking at the same memory is also not.
>
> -----Original Message-----
> From: Dennis Lee Bieber <wlfraed@ix.netcom.com>
> To: python-list@python.org
> Sent: Wed, Feb 2, 2022 12:30 am
> Subject: Re: Data unchanged when passing data to Python in multiprocessing shared memory
>
>
> On Wed, 2 Feb 2022 00:40:22 +0100 (CET), Jen Kris <jenkris@tutanota.com>
>
> declaimed the following:
>
>
>
>>
>>
>> breakup = int.from_bytes(byte_val, "big")
>>
>
> >print("this is breakup " + str(breakup))
>
>>
>>
>
> >Python prints:  this is breakup 32894
>
>>
>>
>
> >Note that I had to switch from little endian to big endian.  Python is little endian by default, but in this case it's big endian. 
>
>>
>>
>
>     Look at the struct module. I'm pretty certain it has flags for big or
>
> little end, or system native (that, or run your integers through the
>
> various "network byte order" functions that I think C and Python both
>
> support.
>
>
>
> https://www.gta.ufrj.br/ensino/eel878/sockets/htonsman.html
>
>
>
>
>
> >However, if anyone on this list knows how to pass data from a non-Python language to Python in multiprocessing.shared_memory please let me (and the list) know. 
>
>
>
>     <pondering>MMU cache lines not writing through to RAM? Can't find
>
> anything on Google to force a cache flush</pondering> Can you test on a
>
> different OS? (Windows vs Linux)
>
>
>
>
>
>
>
> --
>
>     Wulfraed                Dennis Lee Bieber        AF6VN
>
>     wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/
>
> --
>
> https://mail.python.org/mailman/listinfo/python-list
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Re: Data unchanged when passing data to Python in multiprocessing shared memory

<mailman.26.1643855485.2976.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21276&group=comp.lang.python#21276

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: avigross@verizon.net (Avi Gross)
Newsgroups: comp.lang.python
Subject: Re: Data unchanged when passing data to Python in multiprocessing
shared memory
Date: Thu, 3 Feb 2022 02:31:16 +0000 (UTC)
Lines: 228
Message-ID: <mailman.26.1643855485.2976.python-list@python.org>
References: <Muqv9er--3-2@tutanota.com>
<35BA674C-1AAF-43B3-9203-BBF7472E6AE4@barrys-emacs.org>
<MureHAB----2@tutanota.com>
<mailman.11.1643758824.2976.python-list@python.org>
<s44kvg91u4dbvq1nh2uoaj9gd7o20d5fka@4ax.com>
<706734682.2805722.1643825767629@mail.yahoo.com> <MuvgAhH--3-2@tutanota.com>
<796338694.2916887.1643855476163@mail.yahoo.com>
Reply-To: Avi Gross <avigross@verizon.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de aZRAKgDq9KANNGvvRp8SVwFGwXYVKeT0bZpapFBtxIdw==
Return-Path: <avigross@verizon.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=verizon.net header.i=@verizon.net header.b=ty3XUBud;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.028
X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'knows': 0.04; '2022':
0.05; 'string': 0.07; 'subject:when': 0.07; 'byte': 0.09; 'cc:addr
:python-list': 0.09; 'coordinate': 0.09; 'flags': 0.09;
'know.\xc2\xa0': 0.09; 'lookup': 0.09; 'mechanism': 0.09;
'module.': 0.09; 'obviously,': 0.09; 'order,': 0.09; 'string,':
0.09; 'trivial': 0.09; 'subject:Python': 0.12; 'url:mailman':
0.15; 'memory': 0.15; '(windows': 0.16; '2022,': 0.16;
'anything,': 0.16; 'aside': 0.16; 'avi': 0.16; 'bits': 0.16;
'customized': 0.16; 'email addr:python.org:': 0.16; 'gross': 0.16;
'heavily': 0.16; 'ideal.': 0.16; 'incompatible': 0.16; 'integer':
0.16; 'missed': 0.16; 'something.': 0.16; 'something?': 0.16;
'strings,': 0.16; 'subject:shared': 0.16; 'subject:skip:m 10':
0.16; 'python': 0.16; 'larger': 0.17; 'feb': 0.17; "can't": 0.17;
'cc:addr:python.org': 0.20; 'issue': 0.21; 'language': 0.21;
'machine': 0.22; 'maybe': 0.22; 'lines': 0.23; 'run': 0.23;
'(and': 0.25; 'anything': 0.25; 'skip:- 10': 0.25; 'url-
ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'url:listinfo': 0.25; 'cc:2**0': 0.25; 'url-ip:188.166/16': 0.25;
'anyone': 0.25; 'interact': 0.26; 'done': 0.28; 'url-ip:188/8':
0.31; 'program': 0.31; 'think': 0.32; 'needed,': 0.32; 'raw':
0.32; 'said,': 0.32; 'but': 0.32; "i'm": 0.33; 'there': 0.33;
'same': 0.34; 'header:In-Reply-To:1': 0.34; 'trying': 0.35;
'functions': 0.36; 'missing': 0.37; 'necessarily': 0.37; 'using':
0.37; "it's": 0.37; 'hard': 0.37; 'way': 0.38; 'could': 0.38;
'read': 0.38; 'valid': 0.39; 'list': 0.39; 'use': 0.39; 'shared':
0.39; 'table': 0.39; 'to.': 0.39; 'wed,': 0.39; 'base': 0.40;
'exchange': 0.40; 'support.': 0.40; 'both': 0.40; 'something':
0.40; 'want': 0.40; 'four': 0.60; 'including': 0.60; 'from:':
0.62; 'to:': 0.62; 'seen': 0.62; 'skip:i 20': 0.62; 'lower': 0.62;
'reasonable': 0.62; 'send': 0.63; 'skip:m 20': 0.63; 'between':
0.63; 'pass': 0.64; 'clear': 0.64; 're:': 0.64;
'received:74.6.135': 0.64; 'your': 0.64; 'look': 0.65; 'let':
0.66; 'back': 0.67; 'forget': 0.67; 'right': 0.68; 'adds': 0.69;
'cc:': 0.69; 'end,': 0.69; 'following:': 0.69;
'received:74.6.135.40': 0.69;
'received:sonic302-1.consmr.mail.bf2.yahoo.com': 0.69; 'showed':
0.69; 'subject:Data': 0.71; 'little': 0.73; 'easy': 0.74; 'five':
0.75; 'sent:': 0.78; 'header:Reply-To:1': 0.79; 'left': 0.83;
'"1234"': 0.84; '(such': 0.84; 'allowed,': 0.84; 'characters':
0.84; 'converts': 0.84; 'go,': 0.84; 'hexadecimal': 0.84;
'pointer': 0.84; 'spell': 0.84; 'strings': 0.84; 'subject: \n ':
0.84; 'subject:memory': 0.84; 'unchanged': 0.84; 'url-ip:146/8':
0.84; 'work.\xc2\xa0': 0.84; 'stretch': 0.91; 'shocked': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048;
t=1643855481; bh=NhRSaSrdjSHxwcZ0fMRl46STs2K08NyDU2esm7K9J68=;
h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject:Reply-To;
b=ty3XUBudNWGsEuPiF46M/6CKK2fiOHBkSc4eEUNDUarXk7bF2gQ8vukaFKMbKiOLyADGnq/WtqlNYjb359GCkkL0iLKH3nfyQY2ZuxOA2XEvoXsDYoDc8az0ioGhRSjKWNEPLZpd9TvuuORV9rryXJfCmr/ckGbkjfRLjYG1PvNuwOtsopl08YLT2CIt0RT2cc9mPXwcCG5Uq3fb6M4sqSeRxlGQlEeDYiGH/IXxiOJDbQ2Y0vKMCWp48h+8aJE/bkoDjEVqBZhsYxiR7G7wgtjb30dAOtTypvlIahc4jt6FDyeP723KPYbwIhUgXqMTE3xLzPhdXwy8VJcytJo47w==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
t=1643855481; bh=T453FYpi38oNM789KB06PwGI6TqMkpKc0S6ChRfvVXF=;
h=X-Sonic-MF:Date:From:To:Subject:From:Subject;
b=NOnwiDPMqdVGpxXnY0zcLH47y9kDtFFKo7Ah7OWbZ2ZQTY1zwwr4phmtn7l1cwAq0L54kT0IB5RP8+jlA8BCfV4OlXl3YsL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TLRnCyNXFVq48bPy26MSAxLpaDd5TyNAA4v
aoMH5UJjrrNZtz33sseWyoCEYJL5ua2G4ELQ7fLvvmQkpdDgP28YyrR8Q_us2wAZfSYlmLYz7sZB
MKc9NAHlaewrAx7fGGsGe_FqgBO1Ix3lO_FpFcIHaFWyDdc6kdvR76AF1gMG.ElLXyoftfETG4sj
S7hcxFpPV.mROVNPUaj9rS_kAR4DaLpnQpP3lzq6vIjiLM5sTYIqM0I1Yt683EolLgDfOfpwkXH4
IRqnq9IREOXc0.UT9YXWTvuzFq3xTJUMb2_eCesylH1jrMXkHtXgrsUilmzKMnZnoxAkc2YN.yBu
ZpcmfTnupdGvF55dvDfVpXp_sAvdRnwtwxFgaSLqCjFHQNaUIELCf3kAM3J6E0OWSdzpR7V6Dhg4
QM820
X-Sonic-MF: <avigross@verizon.net>
In-Reply-To: <MuvgAhH--3-2@tutanota.com>
X-Mailer: WebService/1.1.19615 aolwebmail
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <796338694.2916887.1643855476163@mail.yahoo.com>
X-Mailman-Original-References: <Muqv9er--3-2@tutanota.com>
<35BA674C-1AAF-43B3-9203-BBF7472E6AE4@barrys-emacs.org>
<MureHAB----2@tutanota.com>
<mailman.11.1643758824.2976.python-list@python.org>
<s44kvg91u4dbvq1nh2uoaj9gd7o20d5fka@4ax.com>
<706734682.2805722.1643825767629@mail.yahoo.com> <MuvgAhH--3-2@tutanota.com>
 by: Avi Gross - Thu, 3 Feb 2022 02:31 UTC

Jen,

I would not be shocked at incompatibilities in the system described making it hard to exchange anything, including text, but am not clear if there is a limitation of four bytes in what can be shared. For me, a character string can use any number of contiguous bytes in memory that some kind of pointer or table lookup provides access to.

Clearly you could squeeze larger number in by not writing decimals but using hexadecimal notation that adds a to f as valid entries, and of course you can make your own customized base 32 or if you use more symbols (such as upper and lower case as different) you could add a few symbols and stretch it out to base 60 or 64.

Like I said, I may have missed something. If you KNOW that system A will interact with systems B and C and so on, and each machine knows what kind it is, and especially if it knows which kind of machine left it something in shared memory, there has to be a way to coordinate between them. If character strings in ASCII or UTF8 or EBCDIC or some kind of raw are allowed, and used with just a few characters that can spell out numbers, I would think much is possible. If needed, perhaps a fixed size could be set aside and the string use a null terminator if shorter.

Of course if this big-endian issue also scrambles bytes used in strings, forget it.

Or, maybe shared memory is not the easy way to go, even it it might be faster.

-----Original Message-----
From: Jen Kris <jenkris@tutanota.com>
To: Avi Gross <avigross@verizon.net>
Cc: python-list@python.org <python-list@python.org>
Sent: Wed, Feb 2, 2022 1:27 pm
Subject: Re: Data unchanged when passing data to Python in multiprocessing shared memory

An ASCII string will not work.  If you convert 32894 to an ascii string you will have five bytes, but you need four.  In my original post I showed the C program I used to convert any 32-bit number to 4 bytes. 

Feb 2, 2022, 10:16 by python-list@python.org:

I applaud trying to find the right solution but wonder if a more trivial solution is even being considered. It ignores big and little endians and just converts your data into another form and back.

If all you want to do is send an integer that fit in 32 bits or 64 bits, why not convert it to a character string in a form that both machines will see the same way and when read back, convert it back to an integer?

As long as both side see the same string, this can be done in reasonable time and portably.

Or am I missing something? Is "1234" not necessarily seen in the same order, or "1.234e3" or whatever?

Obviously, if the mechanism is heavily used and multiple sides keep reading and even writing the same memory location, this is not ideal. But having different incompatible processors looking at the same memory is also not.

-----Original Message-----

From: Dennis Lee Bieber <wlfraed@ix.netcom.com>

To: python-list@python.org

Sent: Wed, Feb 2, 2022 12:30 am

Subject: Re: Data unchanged when passing data to Python in multiprocessing shared memory

On Wed, 2 Feb 2022 00:40:22 +0100 (CET), Jen Kris <jenkris@tutanota.com>

declaimed the following:

breakup = int.from_bytes(byte_val, "big")

>print("this is breakup " + str(breakup))

>Python prints:  this is breakup 32894

>Note that I had to switch from little endian to big endian.  Python is little endian by default, but in this case it's big endian. 

    Look at the struct module. I'm pretty certain it has flags for big or

little end, or system native (that, or run your integers through the

various "network byte order" functions that I think C and Python both

support.

https://www.gta.ufrj.br/ensino/eel878/sockets/htonsman.html

>However, if anyone on this list knows how to pass data from a non-Python language to Python in multiprocessing.shared_memory please let me (and the list) know. 

    <pondering>MMU cache lines not writing through to RAM? Can't find

anything on Google to force a cache flush</pondering> Can you test on a

different OS? (Windows vs Linux)

--

    Wulfraed                Dennis Lee Bieber        AF6VN

    wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

--

https://mail.python.org/mailman/listinfo/python-list

--

https://mail.python.org/mailman/listinfo/python-list

Re: Data unchanged when passing data to Python in multiprocessing shared memory

<mailman.27.1643855727.2976.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21277&group=comp.lang.python#21277

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: rosuav@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Data unchanged when passing data to Python in multiprocessing
shared memory
Date: Thu, 3 Feb 2022 13:35:15 +1100
Lines: 40
Message-ID: <mailman.27.1643855727.2976.python-list@python.org>
References: <Muqv9er--3-2@tutanota.com>
<35BA674C-1AAF-43B3-9203-BBF7472E6AE4@barrys-emacs.org>
<MureHAB----2@tutanota.com>
<mailman.11.1643758824.2976.python-list@python.org>
<s44kvg91u4dbvq1nh2uoaj9gd7o20d5fka@4ax.com>
<706734682.2805722.1643825767629@mail.yahoo.com>
<MuvgAhH--3-2@tutanota.com> <796338694.2916887.1643855476163@mail.yahoo.com>
<CAPTjJmrvC=R0KnJG_MiWe9i2KOB1twyvyuebcK_tRvLuJspbbw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de vz+NHNwqmJhPgP6R/unjUgdZLEMZ+TTCk1UFycpJCTrQ==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=ChwZUavH;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.020
X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'knows': 0.04; '2022':
0.05; 'issue.': 0.05; 'string': 0.07; 'subject:when': 0.07;
'coordinate': 0.09; 'lookup': 0.09; 'subject:Python': 0.12;
'memory': 0.15; 'problem.': 0.15; 'anything,': 0.16; 'aside':
0.16; 'avi': 0.16; 'chrisa': 0.16; 'customized': 0.16;
'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'gross': 0.16; 'missed': 0.16; 'something.': 0.16; 'strings,':
0.16; 'subject:shared': 0.16; 'subject:skip:m 10': 0.16;
'unlikely': 0.16; 'wrote:': 0.16; 'larger': 0.17; 'feb': 0.17;
"can't": 0.17; 'thu,': 0.19; 'to:addr:python-list': 0.20; 'issue':
0.21; 'machine': 0.22; 'maybe': 0.22; 'problem,': 0.22; "what's":
0.22; 'to:name:python-list@python.org': 0.24; 'help.': 0.25;
'actual': 0.25; 'interact': 0.26; 'think': 0.32; 'needed,': 0.32;
'python-list': 0.32; 'raw': 0.32; 'said,': 0.32; 'message-
id:@mail.gmail.com': 0.32; 'but': 0.32; 'there': 0.33; 'header:In-
Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'using': 0.37; 'received:209.85':
0.37; 'hard': 0.37; 'way': 0.38; 'could': 0.38; 'received:209':
0.39; 'valid': 0.39; 'use': 0.39; 'shared': 0.39; 'table': 0.39;
'to.': 0.39; 'base': 0.40; 'exchange': 0.40; 'serious': 0.40;
'something': 0.40; 'four': 0.60; 'including': 0.60; 'lower': 0.62;
'between': 0.63; 'clear': 0.64; 'your': 0.64; 'forget': 0.67;
'adds': 0.69; 'subject:Data': 0.71; 'offer': 0.71; 'easy': 0.74;
'highly': 0.78; 'left': 0.83; '(such': 0.84; 'allowed,': 0.84;
'characters': 0.84; 'go,': 0.84; 'hexadecimal': 0.84; 'pointer':
0.84; 'spell': 0.84; 'strings': 0.84; 'subject: \n ': 0.84;
'subject:memory': 0.84; 'switching': 0.84; 'stretch': 0.91;
'shocked': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:content-transfer-encoding;
bh=FGhtfen6n4MeiKRtO6hMV1+XZUfYnKqAP3ud9P+k/3w=;
b=ChwZUavHB7URRobuETl8OCJe8e06Ox6Ad4AK/NC3nrAC/UCt3Ihz/OHZwHiYx0FzNO
v5MHoH3EHdE/6CBOkaKDLX7n49dcZSKsoLjPEm0lOtO7/BkNXBvKmsW33A7sOcLql8oq
6bqKGQY5mxPsYxKsFEigJTViQF3v5BqJt+DC8NUHcHgoqV0auNFxulb2gtQnFB+72q1U
1E7lRnpr/WaWAdA+8Fy5e4YBIaQ89ClQHRrsKFxiXAlOaCqLIvgEcs4SLKcrRTakmfGO
x+0ZyZRe+XesxndUeY3lcmghGAfPEcSAxxCVmOpgDOZ0s2k9gNeG9puayZj7Cfnhga1a
asyQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:content-transfer-encoding;
bh=FGhtfen6n4MeiKRtO6hMV1+XZUfYnKqAP3ud9P+k/3w=;
b=aJcFBbNW5jT5e7nM/K6ahigWbjDNQVHQYcE7Ndt/ynZ+hTr+a1v1PhNHoWPDGf3PzV
38CjJ3RHT+rJtyRlyiD5I77t2Y8NCygsqDLp9Ta9r50bBHcoYW5h0crIVtJAtVcqZXjY
t3pMKAVeMEKiiGYBjSALtzmLlPLYfrLzLIZOi6XuH5a2YhEk7xHfC61UTnxsNl2dszwX
4Pd5jz9jOYrvt7Vp1FPnUm1U/+vVZ+xPsRX+z3XgpbmpAuIpEVrXi+bTaZnRnsdPve0G
wsbkLXW6JVcgWk2a77hwWxnrTOM2BbdwtDg+GVg4IxALE44456hc1rxYc5dYKIFiHynl
ztvg==
X-Gm-Message-State: AOAM533S08bMnDYCOYXRjzffgAgpE081Mi+4XhgGHieVHcHtPyIhQ/yD
Cy+/rV/3h4sPHAbg2vmsg0yN19FS0Jlj9/BQ3xb2PR0s
X-Google-Smtp-Source: ABdhPJy4x6p0qR//piPRd8i3/OtL8DjEC9s67fDZQmPiuObvSaYTLzhXqyeEPQvGVcB7gxBjkAhWRSwBxGATFum5JA8=
X-Received: by 2002:a05:600c:4e4f:: with SMTP id
e15mr8586449wmq.53.1643855726534;
Wed, 02 Feb 2022 18:35:26 -0800 (PST)
In-Reply-To: <796338694.2916887.1643855476163@mail.yahoo.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmrvC=R0KnJG_MiWe9i2KOB1twyvyuebcK_tRvLuJspbbw@mail.gmail.com>
X-Mailman-Original-References: <Muqv9er--3-2@tutanota.com>
<35BA674C-1AAF-43B3-9203-BBF7472E6AE4@barrys-emacs.org>
<MureHAB----2@tutanota.com>
<mailman.11.1643758824.2976.python-list@python.org>
<s44kvg91u4dbvq1nh2uoaj9gd7o20d5fka@4ax.com>
<706734682.2805722.1643825767629@mail.yahoo.com>
<MuvgAhH--3-2@tutanota.com> <796338694.2916887.1643855476163@mail.yahoo.com>
 by: Chris Angelico - Thu, 3 Feb 2022 02:35 UTC

On Thu, 3 Feb 2022 at 13:32, Avi Gross via Python-list
<python-list@python.org> wrote:
>
> Jen,
>
> I would not be shocked at incompatibilities in the system described making it hard to exchange anything, including text, but am not clear if there is a limitation of four bytes in what can be shared. For me, a character string can use any number of contiguous bytes in memory that some kind of pointer or table lookup provides access to.
>
> Clearly you could squeeze larger number in by not writing decimals but using hexadecimal notation that adds a to f as valid entries, and of course you can make your own customized base 32 or if you use more symbols (such as upper and lower case as different) you could add a few symbols and stretch it out to base 60 or 64.
>
> Like I said, I may have missed something. If you KNOW that system A will interact with systems B and C and so on, and each machine knows what kind it is, and especially if it knows which kind of machine left it something in shared memory, there has to be a way to coordinate between them. If character strings in ASCII or UTF8 or EBCDIC or some kind of raw are allowed, and used with just a few characters that can spell out numbers, I would think much is possible. If needed, perhaps a fixed size could be set aside and the string use a null terminator if shorter.
>
> Of course if this big-endian issue also scrambles bytes used in strings, forget it.
>
> Or, maybe shared memory is not the easy way to go, even it it might be faster.
>

Structs are fine, and are highly unlikely to be the OP's problem.
Switching to a different system won't help.

Unfortunately I can't offer any serious help about the actual problem,
as I don't know what's going on with the shared memory issue.

ChrisA


devel / comp.lang.python / Re: Data unchanged when passing data to Python in multiprocessing shared memory

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor