Mailing List Archive

bpo-40280: Optimize ints and and startup on wasm (GH-29887)
https://github.com/python/cpython/commit/cb8f491f46e262549f6c447b31625cab7c20a60a
commit: cb8f491f46e262549f6c447b31625cab7c20a60a
branch: main
author: Christian Heimes <christian@python.org>
committer: tiran <christian@python.org>
date: 2021-12-02T12:19:30+01:00
summary:

bpo-40280: Optimize ints and and startup on wasm (GH-29887)

files:
M Include/pyport.h
M Python/pylifecycle.c

diff --git a/Include/pyport.h b/Include/pyport.h
index 953f75c970d83..81b1bde841e08 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -87,13 +87,17 @@ Used in: Py_SAFE_DOWNCAST

/* If PYLONG_BITS_IN_DIGIT is not defined then we'll use 30-bit digits if all
the necessary integer types are available, and we're on a 64-bit platform
- (as determined by SIZEOF_VOID_P); otherwise we use 15-bit digits. */
+ (as determined by SIZEOF_VOID_P); otherwise we use 15-bit digits.
+
+ From pyodide: WASM has 32 bit pointers but has native 64 bit arithmetic
+ so it is more efficient to use 30 bit digits.
+ */

#ifndef PYLONG_BITS_IN_DIGIT
-#if SIZEOF_VOID_P >= 8
-#define PYLONG_BITS_IN_DIGIT 30
+#if SIZEOF_VOID_P >= 8 || defined(__wasm__)
+# define PYLONG_BITS_IN_DIGIT 30
#else
-#define PYLONG_BITS_IN_DIGIT 15
+# define PYLONG_BITS_IN_DIGIT 15
#endif
#endif

diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 74d269b7a5646..c6b2a1eb96148 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -2145,7 +2145,11 @@ is_valid_fd(int fd)
if (fd < 0) {
return 0;
}
-#if defined(F_GETFD) && (defined(__linux__) || defined(__APPLE__) || defined(MS_WINDOWS))
+#if defined(F_GETFD) && ( \
+ defined(__linux__) || \
+ defined(__APPLE__) || \
+ defined(MS_WINDOWS) || \
+ defined(__wasm__))
int res;
_Py_BEGIN_SUPPRESS_IPH
res = fcntl(fd, F_GETFD);

_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins