This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Slowdown and high memory usage when adding a new module in embedded Python 3.4 on 64bit Windows
Type: performance Stage: resolved
Components: Build, Extension Modules Versions: Python 3.4
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: MrValdez, methane, steve.dower, vstinner
Priority: normal Keywords:

Created on 2014-03-31 10:35 by MrValdez, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (9)
msg215227 - (view) Author: MrValdez (MrValdez) Date: 2014-03-31 10:35
The example in the "Extending Embedded Python" (https://docs.python.org/3/extending/embedding.html#extending-embedded-python) takes up a lot of memory and slow downs the computer. I am using Windows 7 64bit, Python 3.4 64bit and gcc (rubenvb-4.8.0) 4.8.0.

Solution:

Apparently, you need to add this to your C program:

#define HAVE_SSIZE_T

I found the solution at (https://forums.embarcadero.com/message.jspa?messageID=581594). The page said that when adding the above, "this ensures that the type Py_ssize_t becomes __int64 instead of int."


Expected: 

The programmer should not see a simple program (that came from the main documentation, no less) causing slowdowns and high memory usage. The 64bit version of the Python installer was downloaded so the programmer should, at least, not need to know that they need this flag. 

Can the Python.h in the 64 bit builds automatically set the flag? Or, if this isn't feasible, add a note to the documentation that this flag exist.
msg238892 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2015-03-22 10:33
Who is best placed to address this issue?
msg340010 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-04-12 07:08
Is this issue still alive?
May I close this issue as "out of date"?
msg340030 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-12 12:18
Steve: Are you aware of this issue? "Apparently, you need to add this to your C program: #define HAVE_SSIZE_T"
msg340093 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2019-04-12 18:08
Never heard of it, but perhaps there are some preprocessor checks for Windows that assume you are using MSVC and not gcc?

We don't support compilers other than MSVC on Windows, but if someone has a fix for this I'm happy to consider it.
msg340149 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-04-13 09:44
* rubenvb is not maintained.
* https://forums.embarcadero.com/message.jspa?messageID=581594 is dead link.
* When PY_SSIZE_T is not defined, we use intptr_t, not int.

Original issue report doesn't make sense to me.
But we can't confirm it for now.
msg340159 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-13 14:03
In case of doubt, I suggest to close the issue. If the issue strikes back,
it is trivial to reopen the issue or open a new one.
msg340162 - (view) Author: MrValdez (MrValdez) Date: 2019-04-13 14:55
Its a shame the link is now gone. Its also been a long time that I don't remember all the details.

I still have my code from back when I found this bug. I can try to replicate it.

> We don't support compilers other than MSVC on Windows
> [...]
> rubenvb is not maintained.

I don't remember why I used rubenvb back then. I'll see if I can get MSVC working. Maybe this is the cause for the slow down.
msg344349 - (view) Author: MrValdez (MrValdez) Date: 2019-06-03 00:53
I couldn't replicate since my old dev machine didn't have rubenvb.

Since this issue has been around for 5 years already, rubenvb isn't maintained and I couldn't replicate, I think its fine to close this issue.
History
Date User Action Args
2022-04-11 14:58:01adminsetgithub: 65309
2019-06-03 00:53:11MrValdezsetstatus: open -> closed
resolution: out of date
messages: + msg344349

stage: resolved
2019-04-13 14:55:02MrValdezsetmessages: + msg340162
2019-04-13 14:03:38vstinnersetmessages: + msg340159
2019-04-13 09:44:16methanesetmessages: + msg340149
2019-04-12 18:08:58steve.dowersetmessages: + msg340093
2019-04-12 12:18:30vstinnersetnosy: + steve.dower
messages: + msg340030
2019-04-12 07:08:35methanesetnosy: + methane
messages: + msg340010
2019-03-15 22:20:03BreamoreBoysetnosy: - BreamoreBoy
2015-03-22 10:33:49BreamoreBoysetnosy: + BreamoreBoy
messages: + msg238892
components: + Build, Extension Modules, - Windows
2014-03-31 10:55:02vstinnersetnosy: + vstinner
2014-03-31 10:35:23MrValdezcreate