[Python-Dev] How to keep Signaling NaN unchanged when convert hex to single-precision float ?

2021-04-26 Thread Huang, Yang
Hi,

Code snippet 1 and 2 convert an hex to float, but the SNaN is changed to QNaN 
automatically. It follows IEEE 754 behavior.
While Code snippet 3 converts an hex to double, and  the SNaN keeps.
Is there any solution to keep SNaN float unchanged in Code snippet 1 and 2?


  1.  >>> i = int('7f81', 16)
>>> cp = pointer(c_uint32(i))
>>> fp = cast(cp, POINTER(c_float))
>>> print(fp.contents.value) # nan
>>> print(struct.pack(">f", fp.contents.value).hex())
7fc1


  1.  >>> f = struct.unpack('!f', bytes.fromhex('7f81'))[0]

>>> f  # nan

>>> hex(struct.unpack('>> i = int('7FF1', 16)

>>> cp = pointer(c_uint64(i))

>>> fp = cast(cp, POINTER(c_double))

>>> print(fp.contents.value)

nan

>>> print(struct.pack(">d", fp.contents.value).hex())

7ff1

Thank you in advance!

___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/BNVV6CWSHWLMBE2QJDZZ2N5VNJQAICT6/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] How to customize CPython to a minimal set

2020-07-20 Thread Huang, Yang


Hi, all

There is a request to run python in a Linux-based embedded resource constrained 
system with sqlite3 support.

So many features are not required, like posixmodule, signalmodule, hashtable ...
But seems there are some dependencies among the 
Modules/Parser/Python/Objects/Programs...

Is there a way to tailor CPython 3 to a minimal set with sqlite3 (the less 
syscalls the better) ? 
Is it possible to do that?

Thank you.
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/ECPLKXQ42VNLHD5DP3RG57L3QTJ77FUT/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: How to customize CPython to a minimal set

2020-07-21 Thread Huang, Yang
Hi, Guido

Yes. Micropyhton is also in consideration.
But sqlite3 is the first usage. There should be some additional features like 
numpy, scipy... Not sure if micropython supports well?

Or is there a feasible way to strip CPython ?

Thanks.

From: Guido van Rossum 
Sent: Monday, July 20, 2020 10:45 PM
To: Huang, Yang 
Cc: python-dev@python.org
Subject: Re: [Python-Dev] How to customize CPython to a minimal set

Have you considered starting with micropython? It’s made for embedded systems 
and fully supports Python 3 syntax. Adding sqlite3 support to it will be less 
work than stripping all the I/O from CPython.

—Guido

On Mon, Jul 20, 2020 at 06:48 Huang, Yang 
mailto:yang.hu...@intel.com>> wrote:

Hi, all

There is a request to run python in a Linux-based embedded resource constrained 
system with sqlite3 support.

So many features are not required, like posixmodule, signalmodule, hashtable ...
But seems there are some dependencies among the 
Modules/Parser/Python/Objects/Programs...

Is there a way to tailor CPython 3 to a minimal set with sqlite3 (the less 
syscalls the better) ?
Is it possible to do that?

Thank you.
___
Python-Dev mailing list -- python-dev@python.org<mailto:python-dev@python.org>
To unsubscribe send an email to 
python-dev-le...@python.org<mailto:python-dev-le...@python.org>
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/ECPLKXQ42VNLHD5DP3RG57L3QTJ77FUT/
Code of Conduct: http://python.org/psf/codeofconduct/
--
--Guido (mobile)
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/CVRL4VTGITKVHLHHTZR5HBCZ4EK2WIPE/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: How to customize CPython to a minimal set

2020-07-22 Thread Huang, Yang
Thank you for all your comments.
I cannot agree any more. I did try but there were so many dependencies. One 
change all change.

Micropython is a choice. But not sure if numpy and sqlite3 can be supported 
well. And what’s the compatibility of the libs in Pypi.


From: Guido van Rossum 
Sent: Tuesday, July 21, 2020 10:57 PM
To: Huang, Yang 
Cc: python-dev@python.org
Subject: Re: [Python-Dev] How to customize CPython to a minimal set

I expect it will be unfeasible to strip CPython. If you disagree, try it. ;-)

On Mon, Jul 20, 2020 at 22:35 Huang, Yang 
mailto:yang.hu...@intel.com>> wrote:
Hi, Guido

Yes. Micropyhton is also in consideration.
But sqlite3 is the first usage. There should be some additional features like 
numpy, scipy... Not sure if micropython supports well?

Or is there a feasible way to strip CPython ?

Thanks.

From: Guido van Rossum mailto:gu...@python.org>>
Sent: Monday, July 20, 2020 10:45 PM
To: Huang, Yang mailto:yang.hu...@intel.com>>
Cc: python-dev@python.org<mailto:python-dev@python.org>
Subject: Re: [Python-Dev] How to customize CPython to a minimal set

Have you considered starting with micropython? It’s made for embedded systems 
and fully supports Python 3 syntax. Adding sqlite3 support to it will be less 
work than stripping all the I/O from CPython.

—Guido

On Mon, Jul 20, 2020 at 06:48 Huang, Yang 
mailto:yang.hu...@intel.com>> wrote:

Hi, all

There is a request to run python in a Linux-based embedded resource constrained 
system with sqlite3 support.

So many features are not required, like posixmodule, signalmodule, hashtable ...
But seems there are some dependencies among the 
Modules/Parser/Python/Objects/Programs...

Is there a way to tailor CPython 3 to a minimal set with sqlite3 (the less 
syscalls the better) ?
Is it possible to do that?

Thank you.
___
Python-Dev mailing list -- python-dev@python.org<mailto:python-dev@python.org>
To unsubscribe send an email to 
python-dev-le...@python.org<mailto:python-dev-le...@python.org>
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/ECPLKXQ42VNLHD5DP3RG57L3QTJ77FUT/
Code of Conduct: http://python.org/psf/codeofconduct/
--
--Guido (mobile)
--
--Guido (mobile)
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/OMUGASSNBFJOT3W2ES4OIOQ4LOWMNHHG/
Code of Conduct: http://python.org/psf/codeofconduct/