README.md

This commit is contained in:
zefirova.am 2023-10-12 17:14:36 +03:00
parent abd7769c14
commit cf5ccaacfb
127 changed files with 8220 additions and 0 deletions

View File

@ -45,3 +45,14 @@ make html
Open file://wsl.localhost/Ubuntu/home/zefirka/advanced-python-homework-2023/doc/build/html/index.html
***Tadam***
## 3. Function running time for different interpreters
| | CPython3.9 | CPython3.11| PyPy7.3 |
|-----------|------------|------------|-----------|
| without TH| 0.395806057| 0.23031235 |0.099493876|
| with TH | 0.398283844| 0.223160335|0.109582296|
| with numpy| 0.69133805 | 0.473824731|5.184651649|
| user+sys | 1.689+0.308| 1.066+0.319|6.215+0.350|
PyPy 5.7 didn't download due to error: '...libffi.so.6: cannot open shared object file: No such file or directory'. It's too hard than requied: I did my homework in WSL.

View File

@ -0,0 +1,247 @@
<#
.Synopsis
Activate a Python virtual environment for the current PowerShell session.
.Description
Pushes the python executable for a virtual environment to the front of the
$Env:PATH environment variable and sets the prompt to signify that you are
in a Python virtual environment. Makes use of the command line switches as
well as the `pyvenv.cfg` file values present in the virtual environment.
.Parameter VenvDir
Path to the directory that contains the virtual environment to activate. The
default value for this is the parent of the directory that the Activate.ps1
script is located within.
.Parameter Prompt
The prompt prefix to display when this virtual environment is activated. By
default, this prompt is the name of the virtual environment folder (VenvDir)
surrounded by parentheses and followed by a single space (ie. '(.venv) ').
.Example
Activate.ps1
Activates the Python virtual environment that contains the Activate.ps1 script.
.Example
Activate.ps1 -Verbose
Activates the Python virtual environment that contains the Activate.ps1 script,
and shows extra information about the activation as it executes.
.Example
Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
Activates the Python virtual environment located in the specified location.
.Example
Activate.ps1 -Prompt "MyPython"
Activates the Python virtual environment that contains the Activate.ps1 script,
and prefixes the current prompt with the specified string (surrounded in
parentheses) while the virtual environment is active.
.Notes
On Windows, it may be required to enable this Activate.ps1 script by setting the
execution policy for the user. You can do this by issuing the following PowerShell
command:
PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
For more information on Execution Policies:
https://go.microsoft.com/fwlink/?LinkID=135170
#>
Param(
[Parameter(Mandatory = $false)]
[String]
$VenvDir,
[Parameter(Mandatory = $false)]
[String]
$Prompt
)
<# Function declarations --------------------------------------------------- #>
<#
.Synopsis
Remove all shell session elements added by the Activate script, including the
addition of the virtual environment's Python executable from the beginning of
the PATH variable.
.Parameter NonDestructive
If present, do not remove this function from the global namespace for the
session.
#>
function global:deactivate ([switch]$NonDestructive) {
# Revert to original values
# The prior prompt:
if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
}
# The prior PYTHONHOME:
if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
}
# The prior PATH:
if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
Remove-Item -Path Env:_OLD_VIRTUAL_PATH
}
# Just remove the VIRTUAL_ENV altogether:
if (Test-Path -Path Env:VIRTUAL_ENV) {
Remove-Item -Path env:VIRTUAL_ENV
}
# Just remove VIRTUAL_ENV_PROMPT altogether.
if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
Remove-Item -Path env:VIRTUAL_ENV_PROMPT
}
# Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
}
# Leave deactivate function in the global namespace if requested:
if (-not $NonDestructive) {
Remove-Item -Path function:deactivate
}
}
<#
.Description
Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
given folder, and returns them in a map.
For each line in the pyvenv.cfg file, if that line can be parsed into exactly
two strings separated by `=` (with any amount of whitespace surrounding the =)
then it is considered a `key = value` line. The left hand string is the key,
the right hand is the value.
If the value starts with a `'` or a `"` then the first and last character is
stripped from the value before being captured.
.Parameter ConfigDir
Path to the directory that contains the `pyvenv.cfg` file.
#>
function Get-PyVenvConfig(
[String]
$ConfigDir
) {
Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
# Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
$pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
# An empty map will be returned if no config file is found.
$pyvenvConfig = @{ }
if ($pyvenvConfigPath) {
Write-Verbose "File exists, parse `key = value` lines"
$pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
$pyvenvConfigContent | ForEach-Object {
$keyval = $PSItem -split "\s*=\s*", 2
if ($keyval[0] -and $keyval[1]) {
$val = $keyval[1]
# Remove extraneous quotations around a string value.
if ("'""".Contains($val.Substring(0, 1))) {
$val = $val.Substring(1, $val.Length - 2)
}
$pyvenvConfig[$keyval[0]] = $val
Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
}
}
}
return $pyvenvConfig
}
<# Begin Activate script --------------------------------------------------- #>
# Determine the containing directory of this script
$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
$VenvExecDir = Get-Item -Path $VenvExecPath
Write-Verbose "Activation script is located in path: '$VenvExecPath'"
Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
# Set values required in priority: CmdLine, ConfigFile, Default
# First, get the location of the virtual environment, it might not be
# VenvExecDir if specified on the command line.
if ($VenvDir) {
Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
}
else {
Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
$VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
Write-Verbose "VenvDir=$VenvDir"
}
# Next, read the `pyvenv.cfg` file to determine any required value such
# as `prompt`.
$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
# Next, set the prompt from the command line, or the config file, or
# just use the name of the virtual environment folder.
if ($Prompt) {
Write-Verbose "Prompt specified as argument, using '$Prompt'"
}
else {
Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
$Prompt = $pyvenvCfg['prompt'];
}
else {
Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
$Prompt = Split-Path -Path $venvDir -Leaf
}
}
Write-Verbose "Prompt = '$Prompt'"
Write-Verbose "VenvDir='$VenvDir'"
# Deactivate any currently active virtual environment, but leave the
# deactivate function in place.
deactivate -nondestructive
# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
# that there is an activated venv.
$env:VIRTUAL_ENV = $VenvDir
if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
Write-Verbose "Setting prompt to '$Prompt'"
# Set the prompt to include the env name
# Make sure _OLD_VIRTUAL_PROMPT is global
function global:_OLD_VIRTUAL_PROMPT { "" }
Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
function global:prompt {
Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
_OLD_VIRTUAL_PROMPT
}
$env:VIRTUAL_ENV_PROMPT = $Prompt
}
# Clear PYTHONHOME
if (Test-Path -Path Env:PYTHONHOME) {
Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
Remove-Item -Path Env:PYTHONHOME
}
# Add the venv to the PATH
Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"

View File

@ -0,0 +1,69 @@
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
deactivate () {
# reset old environment variables
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
PATH="${_OLD_VIRTUAL_PATH:-}"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
PS1="${_OLD_VIRTUAL_PS1:-}"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset VIRTUAL_ENV
unset VIRTUAL_ENV_PROMPT
if [ ! "${1:-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}
# unset irrelevant variables
deactivate nondestructive
VIRTUAL_ENV="/home/zefirka/advanced-python-homework/time_execution/3_11_cpython"
export VIRTUAL_ENV
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
if [ -n "${PYTHONHOME:-}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
unset PYTHONHOME
fi
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1:-}"
PS1="(3_11_cpython) ${PS1:-}"
export PS1
VIRTUAL_ENV_PROMPT="(3_11_cpython) "
export VIRTUAL_ENV_PROMPT
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi

View File

@ -0,0 +1,26 @@
# This file must be used with "source bin/activate.csh" *from csh*.
# You cannot run it directly.
# Created by Davide Di Blasi <davidedb@gmail.com>.
# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate'
# Unset irrelevant variables.
deactivate nondestructive
setenv VIRTUAL_ENV "/home/zefirka/advanced-python-homework/time_execution/3_11_cpython"
set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
set _OLD_VIRTUAL_PROMPT="$prompt"
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
set prompt = "(3_11_cpython) $prompt"
setenv VIRTUAL_ENV_PROMPT "(3_11_cpython) "
endif
alias pydoc python -m pydoc
rehash

View File

@ -0,0 +1,69 @@
# This file must be used with "source <venv>/bin/activate.fish" *from fish*
# (https://fishshell.com/); you cannot run it directly.
function deactivate -d "Exit virtual environment and return to normal shell environment"
# reset old environment variables
if test -n "$_OLD_VIRTUAL_PATH"
set -gx PATH $_OLD_VIRTUAL_PATH
set -e _OLD_VIRTUAL_PATH
end
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
set -e _OLD_VIRTUAL_PYTHONHOME
end
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
set -e _OLD_FISH_PROMPT_OVERRIDE
# prevents error when using nested fish instances (Issue #93858)
if functions -q _old_fish_prompt
functions -e fish_prompt
functions -c _old_fish_prompt fish_prompt
functions -e _old_fish_prompt
end
end
set -e VIRTUAL_ENV
set -e VIRTUAL_ENV_PROMPT
if test "$argv[1]" != "nondestructive"
# Self-destruct!
functions -e deactivate
end
end
# Unset irrelevant variables.
deactivate nondestructive
set -gx VIRTUAL_ENV "/home/zefirka/advanced-python-homework/time_execution/3_11_cpython"
set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
# Unset PYTHONHOME if set.
if set -q PYTHONHOME
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
set -e PYTHONHOME
end
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# fish uses a function instead of an env var to generate the prompt.
# Save the current fish_prompt function as the function _old_fish_prompt.
functions -c fish_prompt _old_fish_prompt
# With the original prompt function renamed, we can override with our own.
function fish_prompt
# Save the return status of the last command.
set -l old_status $status
# Output the venv prompt; color taken from the blue of the Python logo.
printf "%s%s%s" (set_color 4B8BBE) "(3_11_cpython) " (set_color normal)
# Restore the return status of the previous command.
echo "exit $old_status" | .
# Output the original/"old" prompt.
_old_fish_prompt
end
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
set -gx VIRTUAL_ENV_PROMPT "(3_11_cpython) "
end

View File

@ -0,0 +1,8 @@
#!/home/zefirka/advanced-python-homework/time_execution/3_11_cpython/bin/python3.11
# -*- coding: utf-8 -*-
import re
import sys
from numpy.f2py.f2py2e import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -0,0 +1,8 @@
#!/home/zefirka/advanced-python-homework/time_execution/3_11_cpython/bin/python3.11
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -0,0 +1,8 @@
#!/home/zefirka/advanced-python-homework/time_execution/3_11_cpython/bin/python3.11
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -0,0 +1,8 @@
#!/home/zefirka/advanced-python-homework/time_execution/3_11_cpython/bin/python3.11
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -0,0 +1 @@
python3.11

View File

@ -0,0 +1 @@
python3.11

View File

@ -0,0 +1 @@
/usr/bin/python3.11

View File

@ -0,0 +1 @@
lib

View File

@ -0,0 +1,5 @@
home = /usr/bin
include-system-site-packages = false
version = 3.11.5
executable = /usr/bin/python3.11
command = /usr/bin/python3.11 -m venv /home/zefirka/advanced-python-homework/time_execution/3_11_cpython

View File

@ -0,0 +1,241 @@
<#
.Synopsis
Activate a Python virtual environment for the current PowerShell session.
.Description
Pushes the python executable for a virtual environment to the front of the
$Env:PATH environment variable and sets the prompt to signify that you are
in a Python virtual environment. Makes use of the command line switches as
well as the `pyvenv.cfg` file values present in the virtual environment.
.Parameter VenvDir
Path to the directory that contains the virtual environment to activate. The
default value for this is the parent of the directory that the Activate.ps1
script is located within.
.Parameter Prompt
The prompt prefix to display when this virtual environment is activated. By
default, this prompt is the name of the virtual environment folder (VenvDir)
surrounded by parentheses and followed by a single space (ie. '(.venv) ').
.Example
Activate.ps1
Activates the Python virtual environment that contains the Activate.ps1 script.
.Example
Activate.ps1 -Verbose
Activates the Python virtual environment that contains the Activate.ps1 script,
and shows extra information about the activation as it executes.
.Example
Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
Activates the Python virtual environment located in the specified location.
.Example
Activate.ps1 -Prompt "MyPython"
Activates the Python virtual environment that contains the Activate.ps1 script,
and prefixes the current prompt with the specified string (surrounded in
parentheses) while the virtual environment is active.
.Notes
On Windows, it may be required to enable this Activate.ps1 script by setting the
execution policy for the user. You can do this by issuing the following PowerShell
command:
PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
For more information on Execution Policies:
https://go.microsoft.com/fwlink/?LinkID=135170
#>
Param(
[Parameter(Mandatory = $false)]
[String]
$VenvDir,
[Parameter(Mandatory = $false)]
[String]
$Prompt
)
<# Function declarations --------------------------------------------------- #>
<#
.Synopsis
Remove all shell session elements added by the Activate script, including the
addition of the virtual environment's Python executable from the beginning of
the PATH variable.
.Parameter NonDestructive
If present, do not remove this function from the global namespace for the
session.
#>
function global:deactivate ([switch]$NonDestructive) {
# Revert to original values
# The prior prompt:
if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
}
# The prior PYTHONHOME:
if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
}
# The prior PATH:
if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
Remove-Item -Path Env:_OLD_VIRTUAL_PATH
}
# Just remove the VIRTUAL_ENV altogether:
if (Test-Path -Path Env:VIRTUAL_ENV) {
Remove-Item -Path env:VIRTUAL_ENV
}
# Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
}
# Leave deactivate function in the global namespace if requested:
if (-not $NonDestructive) {
Remove-Item -Path function:deactivate
}
}
<#
.Description
Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
given folder, and returns them in a map.
For each line in the pyvenv.cfg file, if that line can be parsed into exactly
two strings separated by `=` (with any amount of whitespace surrounding the =)
then it is considered a `key = value` line. The left hand string is the key,
the right hand is the value.
If the value starts with a `'` or a `"` then the first and last character is
stripped from the value before being captured.
.Parameter ConfigDir
Path to the directory that contains the `pyvenv.cfg` file.
#>
function Get-PyVenvConfig(
[String]
$ConfigDir
) {
Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
# Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
$pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
# An empty map will be returned if no config file is found.
$pyvenvConfig = @{ }
if ($pyvenvConfigPath) {
Write-Verbose "File exists, parse `key = value` lines"
$pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
$pyvenvConfigContent | ForEach-Object {
$keyval = $PSItem -split "\s*=\s*", 2
if ($keyval[0] -and $keyval[1]) {
$val = $keyval[1]
# Remove extraneous quotations around a string value.
if ("'""".Contains($val.Substring(0, 1))) {
$val = $val.Substring(1, $val.Length - 2)
}
$pyvenvConfig[$keyval[0]] = $val
Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
}
}
}
return $pyvenvConfig
}
<# Begin Activate script --------------------------------------------------- #>
# Determine the containing directory of this script
$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
$VenvExecDir = Get-Item -Path $VenvExecPath
Write-Verbose "Activation script is located in path: '$VenvExecPath'"
Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
# Set values required in priority: CmdLine, ConfigFile, Default
# First, get the location of the virtual environment, it might not be
# VenvExecDir if specified on the command line.
if ($VenvDir) {
Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
}
else {
Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
$VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
Write-Verbose "VenvDir=$VenvDir"
}
# Next, read the `pyvenv.cfg` file to determine any required value such
# as `prompt`.
$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
# Next, set the prompt from the command line, or the config file, or
# just use the name of the virtual environment folder.
if ($Prompt) {
Write-Verbose "Prompt specified as argument, using '$Prompt'"
}
else {
Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
$Prompt = $pyvenvCfg['prompt'];
}
else {
Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
$Prompt = Split-Path -Path $venvDir -Leaf
}
}
Write-Verbose "Prompt = '$Prompt'"
Write-Verbose "VenvDir='$VenvDir'"
# Deactivate any currently active virtual environment, but leave the
# deactivate function in place.
deactivate -nondestructive
# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
# that there is an activated venv.
$env:VIRTUAL_ENV = $VenvDir
if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
Write-Verbose "Setting prompt to '$Prompt'"
# Set the prompt to include the env name
# Make sure _OLD_VIRTUAL_PROMPT is global
function global:_OLD_VIRTUAL_PROMPT { "" }
Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
function global:prompt {
Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
_OLD_VIRTUAL_PROMPT
}
}
# Clear PYTHONHOME
if (Test-Path -Path Env:PYTHONHOME) {
Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
Remove-Item -Path Env:PYTHONHOME
}
# Add the venv to the PATH
Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"

View File

@ -0,0 +1,66 @@
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
deactivate () {
# reset old environment variables
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
PATH="${_OLD_VIRTUAL_PATH:-}"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
PS1="${_OLD_VIRTUAL_PS1:-}"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset VIRTUAL_ENV
if [ ! "${1:-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}
# unset irrelevant variables
deactivate nondestructive
VIRTUAL_ENV="/home/zefirka/advanced-python-homework/time_execution/3_9_cpython"
export VIRTUAL_ENV
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
if [ -n "${PYTHONHOME:-}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
unset PYTHONHOME
fi
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1:-}"
PS1="(3_9_cpython) ${PS1:-}"
export PS1
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi

View File

@ -0,0 +1,25 @@
# This file must be used with "source bin/activate.csh" *from csh*.
# You cannot run it directly.
# Created by Davide Di Blasi <davidedb@gmail.com>.
# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate'
# Unset irrelevant variables.
deactivate nondestructive
setenv VIRTUAL_ENV "/home/zefirka/advanced-python-homework/time_execution/3_9_cpython"
set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
set _OLD_VIRTUAL_PROMPT="$prompt"
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
set prompt = "(3_9_cpython) $prompt"
endif
alias pydoc python -m pydoc
rehash

View File

@ -0,0 +1,64 @@
# This file must be used with "source <venv>/bin/activate.fish" *from fish*
# (https://fishshell.com/); you cannot run it directly.
function deactivate -d "Exit virtual environment and return to normal shell environment"
# reset old environment variables
if test -n "$_OLD_VIRTUAL_PATH"
set -gx PATH $_OLD_VIRTUAL_PATH
set -e _OLD_VIRTUAL_PATH
end
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
set -e _OLD_VIRTUAL_PYTHONHOME
end
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
functions -e fish_prompt
set -e _OLD_FISH_PROMPT_OVERRIDE
functions -c _old_fish_prompt fish_prompt
functions -e _old_fish_prompt
end
set -e VIRTUAL_ENV
if test "$argv[1]" != "nondestructive"
# Self-destruct!
functions -e deactivate
end
end
# Unset irrelevant variables.
deactivate nondestructive
set -gx VIRTUAL_ENV "/home/zefirka/advanced-python-homework/time_execution/3_9_cpython"
set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
# Unset PYTHONHOME if set.
if set -q PYTHONHOME
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
set -e PYTHONHOME
end
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# fish uses a function instead of an env var to generate the prompt.
# Save the current fish_prompt function as the function _old_fish_prompt.
functions -c fish_prompt _old_fish_prompt
# With the original prompt function renamed, we can override with our own.
function fish_prompt
# Save the return status of the last command.
set -l old_status $status
# Output the venv prompt; color taken from the blue of the Python logo.
printf "%s%s%s" (set_color 4B8BBE) "(3_9_cpython) " (set_color normal)
# Restore the return status of the previous command.
echo "exit $old_status" | .
# Output the original/"old" prompt.
_old_fish_prompt
end
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
end

View File

@ -0,0 +1,8 @@
#!/home/zefirka/advanced-python-homework/time_execution/3_9_cpython/bin/python3.9
# -*- coding: utf-8 -*-
import re
import sys
from numpy.f2py.f2py2e import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -0,0 +1,8 @@
#!/home/zefirka/advanced-python-homework/time_execution/3_9_cpython/bin/python3.9
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -0,0 +1,8 @@
#!/home/zefirka/advanced-python-homework/time_execution/3_9_cpython/bin/python3.9
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -0,0 +1,8 @@
#!/home/zefirka/advanced-python-homework/time_execution/3_9_cpython/bin/python3.9
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -0,0 +1 @@
python3.9

View File

@ -0,0 +1 @@
python3.9

View File

@ -0,0 +1 @@
/usr/bin/python3.9

View File

@ -0,0 +1 @@
lib

View File

@ -0,0 +1,3 @@
home = /usr/bin
include-system-site-packages = false
version = 3.9.18

View File

@ -0,0 +1,81 @@
def linspace(start, stop, n):
if n == 1:
yield stop
return
h = (stop - start) / (n - 1)
for i in range(n):
yield start + h * i
def mandelbrot_1(pmin = -2.5, pmax= 1.5, qmin = -2, qmax= 2,
ppoints = 200, qpoints = 200, max_iterations = 300, infinity_border = 100):
image = [[0 for i in range(qpoints)] for j in range(ppoints)]
for ip, p in enumerate(linspace(pmin, pmax, ppoints)):
for iq, q in enumerate(linspace(qmin, qmax, qpoints)):
c = p + 1j * q
z = 0
for k in range(max_iterations):
z = z ** 2 + c
if abs(z) > infinity_border:
image[ip][iq] = 1
break
return image
def linspace(start, stop, n):
if n == 1:
yield stop
return
h = (stop - start) / (n - 1)
for i in range(n):
yield start + h * i
def mandelbrot_2(pmin: float = -2.5, pmax: float = 1.5, qmin: float = -2, qmax: float = 2,
ppoints: int = 200, qpoints: int = 200, max_iterations: int = 300, infinity_border: float = 100) -> list[list[int]]:
image: list[list[int]] = [[0 for i in range(qpoints)] for j in range(ppoints)]
for ip, p in enumerate(linspace(pmin, pmax, ppoints)):
for iq, q in enumerate(linspace(qmin, qmax, qpoints)):
c: complex = p + 1j * q
z: complex = 0
for k in range(max_iterations):
z = z ** 2 + c
if abs(z) > infinity_border:
image[ip][iq] = 1
break
return image
import numpy as np
def mandelbrot_3(pmin = -2.5, pmax = 1.5, qmin = -2, qmax = 2,
ppoints = 200, qpoints = 200, max_iterations = 300, infinity_border= 100):
image = np.zeros((ppoints, qpoints))
for ip, p in enumerate(np.linspace(pmin, pmax, ppoints)):
for iq, q in enumerate(np.linspace(qmin, qmax, qpoints)):
c = p + 1j * q
z = 0
for k in range(max_iterations):
z = z ** 2 + c
if abs(z) > infinity_border:
image[ip, iq] = 1
break
return image
import time
if __name__ == '__main__':
tic = time.perf_counter_ns()
image = mandelbrot_1()
toc = time.perf_counter_ns()
print((toc - tic)/1_000_000_000, "s - checked_1")
tic = time.perf_counter_ns()
image = mandelbrot_2()
toc = time.perf_counter_ns()
print((toc - tic)/1_000_000_000, "s - checked_2")
tic = time.perf_counter_ns()
image = mandelbrot_3()
toc = time.perf_counter_ns()
print((toc - tic)/1_000_000_000, "s - checked_3")

Binary file not shown.

View File

@ -0,0 +1,608 @@
#encoding utf-8
License
=======
Except when otherwise stated (look for LICENSE files in directories
or information at the beginning of each file) all software and
documentation in the 'rpython', 'pypy', 'ctype_configure', 'dotviewer',
'demo', 'extra_tests', 'include', 'lib_pypy', 'py', and '_pytest'
directories is licensed as follows:
The MIT License
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
PyPy Copyright holders 2003-2023
--------------------------------
Except when otherwise stated (look for LICENSE files or information at
the beginning of each file) the files in the 'pypy' directory are each
copyrighted by one or more of the following people and organizations:
Armin Rigo
Maciej Fijałkowski
Matti Picus
Carl Friedrich Bolz-Tereick
Antonio Cuni
Amaury Forgeot d'Arc
Ronan Lamy
Samuele Pedroni
Alex Gaynor
Philip Jenvey
Richard Plangger
Brian Kearns
Manuel Jacob
Michael Hudson-Doyle
David Schneider
Holger Krekel
Christian Tismer
Håkan Ardö
Benjamin Peterson
Wim Lavrijsen
Anders Chrigstrom
Eric van Riet Paap
Dan Villiom Podlaski Christiansen
Remi Meier
Richard Emslie
Alexander Schremmer
Lukas Diekmann
Sven Hager
Anders Lehmann
Edd Barrett
Aurelien Campeas
Niklaus Haldimann
Camillo Bruni
Laura Creighton
Toon Verwaest
Leonardo Santagada
Seo Sanghyeon
Romain Guillebert
Ronny Pfannschmidt
Yusuke Izawa
Justin Peel
Raffael Tfirst
David Edelsohn
Anders Hammarquist
Jakub Gustak
Gregor Wegberg
Guido Wesdorp
Lawrence Oluyede
Stefano Rivera
Bartosz Skowron
Daniel Roberts
Adrien Di Mascio
Niko Matsakis
Batuhan Taskaya
Alexander Hesse
Ludovic Aubry
stian
Jacob Hallen
Jason Creighton
Mark Young
Andrew Lawrence
Ondrej Baranovič
Alex Martelli
Spenser Bauman
Michal Bendowski
Jan de Mooij
Stefan Beyer
Tyler Wade
Vincent Legoll
Simon Cross
Michael Foord
muke101
Stephan Diehl
Jean-Paul Calderone
Stefan Schwarzer
Tomek Meka
Valentino Volonghi
Patrick Maupin
Devin Jeanpierre
Bob Ippolito
Bruno Gola
David Malcolm
Yannick Jadoul
Squeaky
Timo Paulssen
Marius Gedminas
Laurence Tratt
Alexandre Fayolle
Nicolas Truessel
Simon Burton
Martin Matusiak
Konstantin Lopuhin
Wenzhu Man
John Witulski
Julian Berman
Jeremy Thurgood
Adrian Kuhn
Dario Bertini
Greg Price
Ivan Sichmann Freitas
Mark Pearse
Tobias Pape
Andreas Stührk
Jean-Philippe St. Pierre
Stian Andreassen
Guido van Rossum
Pavel Vinogradov
William Leslie
Paweł Piotr Przeradowski
Michał Górny
Paul deGrandis
Ilya Osadchiy
Tobias Oberstein
marky1991
Boris Feigin
tav
Taavi Burns
Joannah Nanjekye
Georg Brandl
quejebo
Tadeu Zagallo
Vanessa Freudenberg
Gerald Klix
Wanja Saatkamp
Mike Blume
olliemath
Oscar Nierstrasz
Rami Chowdhury
Stefan H. Muller
Dodan Mihai
Tim Felgentreff
Eugene Oden
Colin Valliant
Henry Mason
Jeff Terrace
David Ripton
Preston Timmons
Vasily Kuznetsov
Pieter Zieschang
Lukas Renggli
Dusty Phillips
Guenter Jantzen
Nils Müller
Amit Regmi
Ned Batchelder
Jasper Schulz
Anton Gulenko
Ben Young
Nicolas Chauvat
Andrew Durdin
Andrew Chambers
Sergey Matyunin
Łukasz Langa
Nicholas Riley
Michael Schneider
Yusuke Tsutsumi
Rocco Moretti
Gintautas Miliauskas
Michael Twomey
Igor Trindade Oliveira
Jason Chu
Yichao Yu
Lucian Branescu Mihaila
anatoly techtonik
Mariano Anaya
Olivier Dormond
Jared Grubb
Karl Bartel
Gabriel Lavoie
Wouter van Heyst
Alecsandru Patrascu
Lin Cheng
Brian Dorsey
Victor Stinner
Andrews Medina
Sebastian Pawluś
Stuart Williams
Toby Watson
Antoine Pitrou
Aaron Iles
Christian Hudon
Daniel Patrick
Justas Sadzevicius
Gasper Zejn
Neil Shepperd
Mikael Schönenberg
Michael Cheng
Stanislaw Halik
Berkin Ilbeyi
Mihnea Saracin
Matt Jackson
Ricky Zhou
Jonathan David Riehl
Anders Qvist
Beatrice During
Elmo Mäntynen
Corbin Simpson
Chirag Jadwani
Faye Zhao
Pauli Virtanen
Mike Pavone
Alan McIntyre
Alexander Sedov
Alex Perry
Floris Bruynooghe
Christopher Pope
Attila Gobi
Vaibhav Sood
Reuben Cummings
Robert Zaremba
David C Ellis
cptpcrd
Felix C. Stegerman
Jens-Uwe Mager
Dan Stromberg
Carl Meyer
Stefano Parmesan
Alexis Daboville
Christian Tismer
Marc Abramowitz
Arjun Naik
Valentina Mukhamedzhanova
Florin Papa
Aaron Gallagher
touilleMan
Tristan Arthur
Anthony Sottile
Arianna Avanzini
Matt Billenstein
Sebastian Berg
Tim Matussek
Jacek Generowicz
Sylvain Thenault
Alejandro J. Cura
Roberto De Ioris
Andrew Dalke
Gabriel
Nathan Taylor
Karl Ramm
Vladimir Kryachko
Lukas Vacek
Jakub Stasiak
Omer Katz
Kunal Grover
Mark Williams
Thomas Hisch
Barry Hart
Tomasz Dziopa
Wenzel Jakob
Lutz Paelike
Ignas Mikalajunas
Martin Blais
Jacob Oscarson
Lene Wagner
Lucio Torre
Henrik Vendelbo
Artur Lisiecki
Travis Francis Athougies
Miguel de Val Borro
Kristjan Valur Jonsson
Christoph Gerum
Yasir Suhail
Tomo Cocoa
Neil Blakey-Milner
Dan Buch
Lars Wassermann
Sergey Kishchenko
Ryan Gonzalez
Ian Foote
David Lievens
Richard Lancaster
Philipp Rustemeuer
Logan Chien
Catalin Gabriel Manciu
Miro Hrončok
Antoine Dupre
Bernd Schoeller
Catalin Fierut
Chris Burr
nimaje
Pierre-Yves DAVID
Alessandro Ogier
Gustavo Niemeyer
Andrew Thompson
Joshua Gilbert
Yusei Tahara
Christopher Armstrong
Anders Sigfridsson
Stephan Busemann
Godefroid Chappelle
Dan Colish
Akira Li
Bobby Impollonia
timo
Anna Katrina Dominguez
Juan Francisco Cantero Hurtado
Ben Darnell
Rafał Gałczyński
Yury V. Zaytsev
Laurens Van Houtven
rafalgalczynski@gmail.com
Jason Michalski
Toni Mattis
Lucas Stadler
Jeong YunWon
Ruochen Huang
Markus Holtermann
Kim Jin Su
Matt Bogosian
Aaron Tubbs
Amber Brown
Nikolay Zinov
florinpapa
Vasantha Ganesh K
Fabio Niephaus
Nate Bragg
afteryu
Andrew Stepanov
Radu Ciorba
Carl Bordum Hansen
Paul Ganssle
Michal Kuffa
joachim-ballmann@bitbucket.org
Vincent Michel
Ram Rachum
Bystroushaak
Ryan Hileman
joserubiovidales@gmail.com
dakarpov@gmail.com
Sreepathi Pai
Georges Racinet
ashwinahuja
Bolutife Ogunsola
cjmcdonald@google.com
Alex Orange
alexprengere
Dennis Sweeney
Kevin Lee
h-vertini
Maxwell Bernstein
Renaud Blanch
Anna Ravencroft
Dinu Gherman
Michael Chermside
Jim Baker
Zooko Wilcox-O Hearn
Daniel Neuhäuser
Konrad Delong
Rodrigo Araújo
Armin Ronacher
Jim Hunziker
Christian Muirhead
Brett Cannon
Chris Lambacher
Dan Loewenherz
coolbutuseless@gmail.com
Christopher Groskopf
Buck Golemon
soareschen
Even Wiik Thomassen
Antony Lee
James Lan
yrttyr
Kristoffer Kleine
Julien Phalip
shoma hosaka
Tomer Chachamu
Flavio Percoco
Markus Unterwaditzer
Mike Bayer
OlivierBlanvillain
jiaaro
James Robert
aliceinwire
Kurt Griffiths
Matthew Miller
Asmo Soinio
Stefan Marr
Boglarka Vezer
Mads Kiilerich
Dan Crosta
Dan Sanders
Ben Mather
Chris Pressey
halgari
Berker Peksag
Roman Podoliaka
Nikolaos-Digenis Karagiannis
Donald Stufft
Volodymyr Vladymyrov
Andrey Churin
Niclas Olofsson
Yaroslav Fedevych
Zearin
Tobias Diaz
Jason Madden
Jonas Pfannschmidt
werat
JohnDoe
Diana Popa
Eli Stevens
pizi
remarkablerocket
reubano@gmail.com
Daniil Yarancev
PavloKapyshin
Graham Markall
Stanisław Halik
Iraklis D.
Petre Vijiac
Min RK
Caleb Hattingh
Steve Papanik
m@funkyhat.org
Tomáš Pružina
gabrielg@ec2-54-146-239-158.compute-1.amazonaws.com
Filip Salomonsson
Johan Forsberg
Evgenii Gorinov
John Aldis
Hervé Beraud
Paul Graydon
whitequark
DeVerne Jones
Zsolt Cserna
Yasen Kiprov
mkuffa
Ivan
Jesdi
paugier
bernd.schoeller@inf.ethz.ch
Sam Edwards
Joannah Nanjekye nanjekyejoannah@gmail.com
Alex Kashirin
Ihar Shabes
kotus9
Mike Kaplinskiy
Henri Tuhola
mark doerr
Tomas Hrnciar
shaolo1
Chris AtLee
Christoph Reiter
Brad Kish
Michael Cho
Ian Clester
David Hewitt
h-vetinari
Isuru Fernando
Heinrich-Heine University, Germany
Open End AB (formerly AB Strakt), Sweden
merlinux GmbH, Germany
tismerysoft GmbH, Germany
Logilab Paris, France
DFKI GmbH, Germany
Impara, Germany
Change Maker, Sweden
University of California Berkeley, USA
Google Inc.
King's College London
The PyPy Logo as used by http://speed.pypy.org and others was created
by Samuel Reis and is distributed on terms of Creative Commons Share Alike
License.
License for 'lib-python/2.7, lib-python/3'
==========================================
Except when otherwise stated (look for LICENSE files or copyright/license
information at the beginning of each file) the files in the 'lib-python'
directory are all copyrighted by the Python Software Foundation and licensed
under the terms that you can find here: https://docs.python.org/3/license.html
License for 'pypy/module/unicodedata/'
======================================
The following files are from the website of The Unicode Consortium
at http://www.unicode.org/. For the terms of use of these files, see
http://www.unicode.org/terms_of_use.html . Or they are derived from
files from the above website, and the same terms of use apply.
CompositionExclusions-*.txt
EastAsianWidth-*.txt
LineBreak-*.txt
UnicodeData-*.txt
UnihanNumeric-*.txt
License for 'dotviewer/font/'
=============================
Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Detailed license information is contained in the NOTICE file in the
directory.
Licenses and Acknowledgements for Incorporated Software
=======================================================
This section is an incomplete, but growing list of licenses and
acknowledgements for third-party software incorporated in the PyPy
distribution.
License for 'Tcl/Tk'
--------------------
This copy of PyPy contains library code that may, when used, result in
the Tcl/Tk library to be loaded. PyPy also includes code that may be
regarded as being a copy of some parts of the Tcl/Tk header files.
You may see a copy of the License for Tcl/Tk in the file
`lib_pypy/_tkinter/license.terms` included here.
License for 'bzip2'
-------------------
This copy of PyPy may be linked (dynamically or statically) with the
bzip2 library. You may see a copy of the License for bzip2/libbzip2 at
http://www.bzip.org/1.0.5/bzip2-manual-1.0.5.html
License for 'openssl'
---------------------
This copy of PyPy may be linked (dynamically or statically) with the
openssl library. You may see a copy of the License for OpenSSL at
https://www.openssl.org/source/license.html
License for '_gdbm'
------------------
The _gdbm module includes code from gdbm.h, which is distributed under
the terms of the GPL license version 2 or any later version. Thus the
_gdbm module, provided in the file lib_pypy/_gdbm.py, is redistributed
under the terms of the GPL license as well.
License for 'rpython/rlib/rvmprof/src'
--------------------------------------
The code is based on gperftools. You may see a copy of the License for it at
https://github.com/gperftools/gperftools/blob/master/COPYING
License for 'liblzma and 'lzmaffi'
----------------------------------
This copy of PyPy may be linked (dynamically or statically) with the
liblzma library, which was put in the "public domain":
http://tukaani.org/xz/
The cffi bindings to liblzma (in lib_pypy/_lzma.py) are derived from
the lzmaffi project which is distributed under a BSD license:
https://pypi.python.org/pypi/lzmaffi/0.3.0

View File

@ -0,0 +1,44 @@
=====================================
PyPy: Python in Python Implementation
=====================================
Welcome to PyPy!
PyPy is an interpreter that implements the Python programming language, based
on the RPython compiler framework for dynamic language implementations.
The home page for the interpreter is:
https://pypy.org/
If you want to help developing PyPy, this documentation might help you:
https://doc.pypy.org/
More documentation about the RPython framework can be found here:
https://rpython.readthedocs.io/
The source for the documentation is in the pypy/doc directory.
Using PyPy instead of CPython
-----------------------------
Please read the information at https://pypy.org/ to find the correct way to
download and use PyPy as an alternative to CPython.
Building
--------
Building PyPy is not the recommended way to obtain the PyPy alternative python
interpreter. It is time-consuming and requires significant computing resources.
More information can be found here:
https://doc.pypy.org/en/latest/build.html
Enjoy and send us feedback!
the pypy-dev team <pypy-dev@python.org>

View File

@ -0,0 +1 @@
pypy3.9

View File

@ -0,0 +1 @@
pypy3.9

Binary file not shown.

View File

@ -0,0 +1 @@
pypy3.9

View File

@ -0,0 +1 @@
pypy3.9

View File

@ -0,0 +1 @@
pypy3.9

View File

@ -0,0 +1,11 @@
This directory contains all the include files needed to build cpython
extensions with PyPy. Note that these are just copies of the original headers
that are in pypy/module/cpyext/{include,parse}: they are automatically copied
from there during translation.
Moreover, some pypy-specific files are automatically generated, also during
translation. Currently they are:
* pypy_decl.h
* pypy_macros.h
* pypy_numpy.h
* pypy_structmember_decl.h

View File

@ -0,0 +1,144 @@
#ifndef Py_PYTHON_H
#define Py_PYTHON_H
#include "patchlevel.h"
#include <pyconfig.h>
/* Compat stuff */
#ifdef __GNUC__
#define _GNU_SOURCE 1
#endif
#ifndef _WIN32
# include <stddef.h>
# include <limits.h>
# include <math.h>
# include <errno.h>
# include <unistd.h>
#else
# ifdef _MSC_VER
# include <crtdefs.h>
# endif
# ifdef __MINGW32__
# include <limits.h>
# endif
# include <io.h>
# include <sys/types.h> /* for 'off_t' */
#endif
/* Deprecated DL_IMPORT and DL_EXPORT macros */
#ifdef _WIN32
# if defined(Py_BUILD_CORE)
# define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE
# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
# else
# define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE
# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
# endif
#endif
#ifndef DL_EXPORT
# define DL_EXPORT(RTYPE) PyAPI_FUNC(RTYPE)
#endif
#ifndef DL_IMPORT
# define DL_IMPORT(RTYPE) RTYPE
#endif
#include <stdlib.h>
#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE)
#define Py_USING_UNICODE
#define statichere static
#define Py_MEMCPY memcpy
#include "pyport.h"
#include "pypy_macros.h"
#include "pymacro.h"
#include "object.h"
#include "typeslots.h"
#include "abstract.h"
#include "pymath.h"
#include "pytime.h"
#include "warnings.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <locale.h>
#include <ctype.h>
#include "pyhash.h"
#include "boolobject.h"
#include "floatobject.h"
#include "complexobject.h"
#include "methodobject.h"
#include "funcobject.h"
#include "code.h"
#include "moduleobject.h"
#include "modsupport.h"
#include "pythonrun.h"
#include "pyerrors.h"
#include "sysmodule.h"
#include "bytearrayobject.h"
#include "descrobject.h"
#include "tupleobject.h"
#include "dictobject.h"
#include "longobject.h"
#include "setobject.h"
#include "listobject.h"
#include "longobject.h"
#include "unicodeobject.h"
#include "compile.h"
#include "frameobject.h"
#include "memoryobject.h"
#include "eval.h"
#include "pymem.h"
#include "pycapsule.h"
#include "bytesobject.h"
#include "sliceobject.h"
#include "genobject.h"
#include "datetime.h"
#include "structseq.h"
#include "pystate.h"
#include "fileobject.h"
#include "pysignals.h"
#include "pythread.h"
#include "traceback.h"
#include "pylifecycle.h"
#include "genericaliasobject.h"
/* Missing definitions */
#include "missing.h"
/* The declarations of most API functions are generated in a separate file */
/* Don't include them while building PyPy, RPython also generated signatures
* which are similar but not identical. */
#ifndef PYPY_STANDALONE
#ifdef __cplusplus
extern "C" {
#endif
#include "pypy_decl.h"
#ifdef __cplusplus
}
#endif
#endif /* PYPY_STANDALONE */
/* Define macros for inline documentation. */
#define PyDoc_VAR(name) static char name[]
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
#ifdef WITH_DOC_STRINGS
#define PyDoc_STR(str) str
#else
#define PyDoc_STR(str) ""
#endif
/* PyPy does not implement --with-fpectl */
#define PyFPE_START_PROTECT(err_string, leave_stmt)
#define PyFPE_END_PROTECT(v)
#include "pystrtod.h"
#endif

View File

@ -0,0 +1,85 @@
#ifndef Py_ABSTRACTOBJECT_H
#define Py_ABSTRACTOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, char *key);
/*
Remove the mapping for object, key, from the object *o.
Returns -1 on failure. This is equivalent to
the Python statement: del o[key].
*/
#define PY_VECTORCALL_ARGUMENTS_OFFSET ((size_t)1 << (8 * sizeof(size_t) - 1))
static inline Py_ssize_t
PyVectorcall_NARGS(size_t n)
{
return n & ~PY_VECTORCALL_ARGUMENTS_OFFSET;
}
/* Call "callable" (which must support vectorcall) with positional arguments
"tuple" and keyword arguments "dict". "dict" may also be NULL */
PyAPI_FUNC(PyObject *) PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict);
// Backwards compatibility aliases for API that was provisional in Python 3.8
#define _PyObject_Vectorcall PyObject_Vectorcall
#define _PyObject_VectorcallMethod PyObject_VectorcallMethod
#define _PyObject_FastCallDict PyObject_VectorcallDict
#define _PyVectorcall_Function PyVectorcall_Function
#define _PyObject_CallOneArg PyObject_CallOneArg
#define _PyObject_CallNoArg PyObject_CallNoArgs
#define _PyObject_CallMethodNoArgs PyObject_CallMethodNoArgs
#define _PyObject_CallMethodOneArg PyObject_CallMethodOneArg
/* new buffer API */
#define PyObject_CheckBuffer(obj) \
(((obj)->ob_type->tp_as_buffer != NULL) && \
((obj)->ob_type->tp_as_buffer->bf_getbuffer != NULL))
/* Return 1 if the getbuffer function is available, otherwise
return 0 */
PyAPI_FUNC(int) PyObject_GetBuffer(PyObject *obj, Py_buffer *view,
int flags);
/* This is a C-API version of the getbuffer function call. It checks
to make sure object has the required function pointer and issues the
call. Returns -1 and raises an error on failure and returns 0 on
success
*/
PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view);
/* Releases a Py_buffer obtained from getbuffer ParseTuple's s*.
*/
/* Mapping protocol:*/
/* implemented as a macro:
int PyMapping_DelItemString(PyObject *o, char *key);
Remove the mapping for object, key, from the object *o.
Returns -1 on failure. This is equivalent to
the Python statement: del o[key].
*/
#define PyMapping_DelItemString(O,K) PyObject_DelItemString((O),(K))
/* implemented as a macro:
int PyMapping_DelItem(PyObject *o, PyObject *key);
Remove the mapping for object, key, from the object *o.
Returns -1 on failure. This is equivalent to
the Python statement: del o[key].
*/
#define PyMapping_DelItem(O,K) PyObject_DelItem((O),(K))
#ifdef __cplusplus
}
#endif
#endif /* Py_ABSTRACTOBJECT_H */

View File

@ -0,0 +1,25 @@
/* Boolean object interface */
#ifndef Py_BOOLOBJECT_H
#define Py_BOOLOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
#define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type)
/* Py_False and Py_True are the only two bools in existence.
Don't forget to apply Py_INCREF() when returning either!!! */
/* Use these macros */
#define Py_False ((PyObject *) &_Py_FalseStruct)
#define Py_True ((PyObject *) &_Py_TrueStruct)
/* Macros for returning Py_True or Py_False, respectively */
#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
#ifdef __cplusplus
}
#endif
#endif /* !Py_BOOLOBJECT_H */

View File

@ -0,0 +1,36 @@
/* ByteArray object interface */
#ifndef Py_BYTEARRAYOBJECT_H
#define Py_BYTEARRAYOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
/* Type PyByteArrayObject represents a mutable array of bytes.
* The Python API is that of a sequence;
* the bytes are mapped to ints in [0, 256).
* Bytes are not characters; they may be used to encode characters.
* The only way to go between bytes and str/unicode is via encoding
* and decoding.
* While CPython exposes interfaces to this object, pypy does not
*/
#define PyByteArray_GET_SIZE(op) PyByteArray_Size((PyObject*)(op))
#define PyByteArray_AS_STRING(op) PyByteArray_AsString((PyObject*)(op))
/* Object layout */
typedef struct {
PyObject_VAR_HEAD
#if 0
int ob_exports; /* how many buffer exports */
Py_ssize_t ob_alloc; /* How many bytes allocated */
char *ob_bytes;
#endif
} PyByteArrayObject;
#ifdef __cplusplus
}
#endif
#endif /* !Py_BYTEARRAYOBJECT_H */

View File

@ -0,0 +1,68 @@
/* A copy of pypy2's PyStringObject */
#ifndef Py_BYTESOBJECT_H
#define Py_BYTESOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#define PyBytes_GET_SIZE(op) PyBytes_Size(op)
/*
Type PyStringObject represents a character string. An extra zero byte is
reserved at the end to ensure it is zero-terminated, but a size is
present so strings with null bytes in them can be represented. This
is an immutable object type.
There are functions to create new string objects, to test
an object for string-ness, and to get the
string value. The latter function returns a null pointer
if the object is not of the proper type.
There is a variant that takes an explicit size as well as a
variant that assumes a zero-terminated string. Note that none of the
functions should be applied to nil objects.
*/
/* Caching the hash (ob_shash) saves recalculation of a string's hash value.
Interning strings (ob_sstate) tries to ensure that only one string
object with a given value exists, so equality tests can be one pointer
comparison. This is generally restricted to strings that "look like"
Python identifiers, although the intern() builtin can be used to force
interning of any string.
Together, these sped cpython up by up to 20%, and since they are part of the
"public" interface PyPy must reimpliment them. */
typedef struct {
PyObject_VAR_HEAD
Py_hash_t ob_shash;
int ob_sstate;
char ob_sval[1];
/* Invariants
* ob_sval contains space for 'ob_size+1' elements.
* ob_sval[ob_size] == 0.
* ob_shash is the hash of the string or -1 if not computed yet.
* ob_sstate != 0 iff the string object is in stringobject.c's
* 'interned' dictionary; in this case the two references
* from 'interned' to this object are *not counted* in ob_refcnt.
*/
} PyBytesObject;
#define SSTATE_NOT_INTERNED 0
#define SSTATE_INTERNED_MORTAL 1
#define SSTATE_INTERNED_IMMORTAL 2
#define PyString_CHECK_INTERNED(op) (((PyStringObject *)(op))->ob_sstate)
#define PyBytes_Check(op) \
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS)
#define PyBytes_CheckExact(op) (Py_TYPE(op) == &PyBytes_Type)
PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list);
PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,73 @@
#ifndef Py_CSTRINGIO_H
#define Py_CSTRINGIO_H
#ifdef __cplusplus
extern "C" {
#endif
/*
This header provides access to cStringIO objects from C.
Functions are provided for calling cStringIO objects and
macros are provided for testing whether you have cStringIO
objects.
Before calling any of the functions or macros, you must initialize
the routines with:
PycString_IMPORT
This would typically be done in your init function.
*/
#define PycStringIO_CAPSULE_NAME "cStringIO.cStringIO_CAPI"
#define PycString_IMPORT \
PycStringIO = ((struct PycStringIO_CAPI*)PyCapsule_Import(\
PycStringIO_CAPSULE_NAME, 0))
/* Basic functions to manipulate cStringIO objects from C */
static struct PycStringIO_CAPI {
/* Read a string from an input object. If the last argument
is -1, the remainder will be read.
*/
int(*cread)(PyObject *, char **, Py_ssize_t);
/* Read a line from an input object. Returns the length of the read
line as an int and a pointer inside the object buffer as char** (so
the caller doesn't have to provide its own buffer as destination).
*/
int(*creadline)(PyObject *, char **);
/* Write a string to an output object*/
int(*cwrite)(PyObject *, const char *, Py_ssize_t);
/* Get the output object as a Python string (returns new reference). */
PyObject *(*cgetvalue)(PyObject *);
/* Create a new output object */
PyObject *(*NewOutput)(int);
/* Create an input object from a Python string
(copies the Python string reference).
*/
PyObject *(*NewInput)(PyObject *);
/* The Python types for cStringIO input and output objects.
Note that you can do input on an output object.
*/
PyTypeObject *InputType, *OutputType;
} *PycStringIO;
/* These can be used to test if you have one */
#define PycStringIO_InputCheck(O) \
(0) /* Py_TYPE(O)==PycStringIO->InputType) */
#define PycStringIO_OutputCheck(O) \
(0) /* Py_TYPE(O)==PycStringIO->OutputType) */
#ifdef __cplusplus
}
#endif
#endif /* !Py_CSTRINGIO_H */

View File

@ -0,0 +1 @@
/* empty */

View File

@ -0,0 +1,38 @@
#ifndef Py_CODE_H
#define Py_CODE_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PyObject_HEAD
PyObject *co_name;
PyObject *co_filename;
int co_argcount;
int co_flags;
} PyCodeObject;
/* Masks for co_flags above */
/* These values are also in funcobject.py */
#define CO_OPTIMIZED 0x0001
#define CO_NEWLOCALS 0x0002
#define CO_VARARGS 0x0004
#define CO_VARKEYWORDS 0x0008
#define CO_NESTED 0x0010
#define CO_GENERATOR 0x0020
/* The CO_COROUTINE flag is set for coroutine functions (defined with
``async def`` keywords) */
#define CO_COROUTINE 0x0080
#define CO_ITERABLE_COROUTINE 0x0100
#define CO_FUTURE_DIVISION 0x020000
#define CO_FUTURE_ABSOLUTE_IMPORT 0x040000
#define CO_FUTURE_WITH_STATEMENT 0x080000
#define CO_FUTURE_PRINT_FUNCTION 0x100000
#define CO_FUTURE_UNICODE_LITERALS 0x200000
#ifdef __cplusplus
}
#endif
#endif /* !Py_CODE_H */

View File

@ -0,0 +1,13 @@
#ifndef Py_COMPILE_H
#define Py_COMPILE_H
#include "code.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* !Py_COMPILE_H */

View File

@ -0,0 +1,25 @@
/* Complex object interface */
#ifndef Py_COMPLEXOBJECT_H
#define Py_COMPLEXOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct Py_complex_t {
double real;
double imag;
} Py_complex;
typedef struct {
PyObject_HEAD
Py_complex cval;
} PyComplexObject;
PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *obj);
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex c);
#ifdef __cplusplus
}
#endif
#endif /* !Py_COMPLEXOBJECT_H */

View File

@ -0,0 +1,66 @@
/* Define structure for C API. */
typedef struct {
/* type objects */
PyTypeObject *DateType;
PyTypeObject *DateTimeType;
PyTypeObject *TimeType;
PyTypeObject *DeltaType;
PyTypeObject *TZInfoType;
/* singletons */
PyObject *TimeZone_UTC;
/* constructors */
PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*);
PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int,
PyObject*, PyTypeObject*);
PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*);
PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*);
PyObject *(*TimeZone_FromTimeZone)(PyObject*, PyObject*);
/* constructors for the DB API */
PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*);
PyObject *(*Date_FromTimestamp)(PyObject*, PyObject*);
/* PEP 495 constructors */
PyObject *(*DateTime_FromDateAndTimeAndFold)(int, int, int, int, int, int, int,
PyObject*, int, PyTypeObject*);
PyObject *(*Time_FromTimeAndFold)(int, int, int, int, PyObject*, int, PyTypeObject*);
} PyDateTime_CAPI;
typedef struct
{
PyObject_HEAD
int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */
int seconds; /* 0 <= seconds < 24*3600 is invariant */
int microseconds; /* 0 <= microseconds < 1000000 is invariant */
} PyDateTime_Delta;
/* The datetime and time types have an optional tzinfo member,
* PyNone if hastzinfo is false.
*/
typedef struct
{
PyObject_HEAD
unsigned char hastzinfo;
PyObject *tzinfo;
} PyDateTime_Time;
typedef struct
{
PyObject_HEAD
unsigned char hastzinfo;
PyObject *tzinfo;
} PyDateTime_DateTime;
typedef struct {
PyObject_HEAD
} PyDateTime_Date;
typedef struct {
PyObject_HEAD
} PyDateTime_TZInfo;

View File

@ -0,0 +1,64 @@
typedef PyObject *(*getter)(PyObject *, void *);
typedef int (*setter)(PyObject *, PyObject *, void *);
typedef struct PyGetSetDef {
const char *name;
getter get;
setter set;
const char *doc;
void *closure;
} PyGetSetDef;
typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
void *wrapped);
typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
void *wrapped, PyObject *kwds);
struct wrapperbase {
const char *name;
int offset;
void *function;
wrapperfunc wrapper;
const char *doc;
int flags;
PyObject *name_strobj;
};
/* Flags for above struct */
#define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */
/* Various kinds of descriptor objects */
typedef struct {
PyObject_HEAD
PyTypeObject *d_type;
PyObject *d_name;
PyObject *d_qualname;
} PyDescrObject;
#define PyDescr_COMMON PyDescrObject d_common
#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
typedef struct {
PyDescr_COMMON;
PyMethodDef *d_method;
} PyMethodDescrObject;
typedef struct {
PyDescr_COMMON;
struct PyMemberDef *d_member;
} PyMemberDescrObject;
typedef struct {
PyDescr_COMMON;
PyGetSetDef *d_getset;
} PyGetSetDescrObject;
typedef struct {
PyDescr_COMMON;
struct wrapperbase *d_base;
void *d_wrapped; /* This can be any function pointer */
} PyWrapperDescrObject;

View File

@ -0,0 +1,4 @@
typedef struct {
PyObject_HEAD
PyObject* gi_code;
} PyGenObject;

View File

@ -0,0 +1,13 @@
/* The struct is declared here but it shouldn't
be considered public. Don't access those fields directly,
use the functions instead! */
/* this is wrong, PyMemoryViewObject should use PyObject_VAR_HEAD, and use
ob_data[1] to hold the shapes, strides, and offsets for the view. Then
we should use specialized allocators (that break the cpyext model) to
allocate ob_data = malloc(sizeof(Py_ssize_t) * view.ndims * 3) */
typedef struct {
PyObject_HEAD
Py_buffer view;
} PyMemoryViewObject;

View File

@ -0,0 +1,44 @@
typedef struct PyModuleDef_Base {
PyObject_HEAD
PyObject* (*m_init)(void);
Py_ssize_t m_index;
PyObject* m_copy;
} PyModuleDef_Base;
#define PyModuleDef_HEAD_INIT { \
PyObject_HEAD_INIT(NULL) \
NULL, /* m_init */ \
0, /* m_index */ \
NULL, /* m_copy */ \
}
struct PyModuleDef_Slot;
/* New in 3.5 */
typedef struct PyModuleDef_Slot{
int slot;
void *value;
} PyModuleDef_Slot;
#define Py_mod_create 1
#define Py_mod_exec 2
#define _Py_mod_LAST_SLOT 2
typedef struct PyModuleDef{
PyModuleDef_Base m_base;
const char* m_name;
const char* m_doc;
Py_ssize_t m_size;
PyMethodDef *m_methods;
struct PyModuleDef_Slot* m_slots;
traverseproc m_traverse;
inquiry m_clear;
freefunc m_free;
} PyModuleDef;
typedef struct {
PyObject_HEAD
struct PyModuleDef *md_def;
void *md_state;
} PyModuleObject;

View File

@ -0,0 +1,323 @@
#pragma once
#define PyObject_HEAD PyObject ob_base;
#define PyObject_VAR_HEAD PyVarObject ob_base;
typedef struct _object {
Py_ssize_t ob_refcnt;
Py_ssize_t ob_pypy_link;
struct _typeobject *ob_type;
} PyObject;
typedef struct {
PyObject ob_base;
Py_ssize_t ob_size; /* Number of items in variable part */
} PyVarObject;
struct _typeobject;
typedef void (*freefunc)(void *);
typedef void (*destructor)(PyObject *);
typedef Py_ssize_t printfunc;
typedef PyObject *(*getattrfunc)(PyObject *, char *);
typedef PyObject *(*getattrofunc)(PyObject *, PyObject *);
typedef int (*setattrfunc)(PyObject *, char *, PyObject *);
typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *);
typedef int (*cmpfunc)(PyObject *, PyObject *);
typedef PyObject *(*reprfunc)(PyObject *);
typedef Py_hash_t (*hashfunc)(PyObject *);
typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int);
typedef PyObject *(*getiterfunc) (PyObject *);
typedef PyObject *(*iternextfunc) (PyObject *);
typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *);
typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *);
typedef int (*initproc)(PyObject *, PyObject *, PyObject *);
typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *);
typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t);
typedef PyObject * (*unaryfunc)(PyObject *);
typedef PyObject * (*binaryfunc)(PyObject *, PyObject *);
typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *);
typedef int (*inquiry)(PyObject *);
typedef Py_ssize_t (*lenfunc)(PyObject *);
typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t);
typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t);
typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *);
typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *);
/* Py3k buffer interface, adapted for PyPy */
/* XXX remove this constant, us a PyObject_VAR_HEAD instead */
#define Py_MAX_NDIMS 36
typedef struct bufferinfo {
void *buf;
PyObject *obj; /* owned reference */
Py_ssize_t len;
Py_ssize_t itemsize; /* This is Py_ssize_t so it can be
pointed to by strides in simple case.*/
int readonly;
int ndim;
char *format;
Py_ssize_t *shape;
Py_ssize_t *strides;
Py_ssize_t *suboffsets; /* alway NULL for app-level objects*/
void *internal; /* always NULL for app-level objects */
/* PyPy extensions */
int flags;
Py_ssize_t _strides[Py_MAX_NDIMS];
Py_ssize_t _shape[Py_MAX_NDIMS];
/* static store for shape and strides of
mono-dimensional buffers. */
/* Py_ssize_t smalltable[2]; */
} Py_buffer;
typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
/* end Py3k buffer interface */
typedef PyObject *(*vectorcallfunc)(PyObject *callable, PyObject *const *args,
size_t nargsf, PyObject *kwnames);
typedef int (*objobjproc)(PyObject *, PyObject *);
typedef int (*visitproc)(PyObject *, void *);
typedef int (*traverseproc)(PyObject *, visitproc, void *);
typedef struct {
/* Number implementations must check *both*
arguments for proper type and implement the necessary conversions
in the slot functions themselves. */
binaryfunc nb_add;
binaryfunc nb_subtract;
binaryfunc nb_multiply;
binaryfunc nb_remainder;
binaryfunc nb_divmod;
ternaryfunc nb_power;
unaryfunc nb_negative;
unaryfunc nb_positive;
unaryfunc nb_absolute;
inquiry nb_bool;
unaryfunc nb_invert;
binaryfunc nb_lshift;
binaryfunc nb_rshift;
binaryfunc nb_and;
binaryfunc nb_xor;
binaryfunc nb_or;
unaryfunc nb_int;
void *nb_reserved; /* the slot formerly known as nb_long */
unaryfunc nb_float;
binaryfunc nb_inplace_add;
binaryfunc nb_inplace_subtract;
binaryfunc nb_inplace_multiply;
binaryfunc nb_inplace_remainder;
ternaryfunc nb_inplace_power;
binaryfunc nb_inplace_lshift;
binaryfunc nb_inplace_rshift;
binaryfunc nb_inplace_and;
binaryfunc nb_inplace_xor;
binaryfunc nb_inplace_or;
binaryfunc nb_floor_divide;
binaryfunc nb_true_divide;
binaryfunc nb_inplace_floor_divide;
binaryfunc nb_inplace_true_divide;
unaryfunc nb_index;
binaryfunc nb_matrix_multiply;
binaryfunc nb_inplace_matrix_multiply;
} PyNumberMethods;
typedef struct {
lenfunc sq_length;
binaryfunc sq_concat;
ssizeargfunc sq_repeat;
ssizeargfunc sq_item;
void *was_sq_slice;
ssizeobjargproc sq_ass_item;
void *was_sq_ass_slice;
objobjproc sq_contains;
binaryfunc sq_inplace_concat;
ssizeargfunc sq_inplace_repeat;
} PySequenceMethods;
typedef struct {
lenfunc mp_length;
binaryfunc mp_subscript;
objobjargproc mp_ass_subscript;
} PyMappingMethods;
typedef struct {
unaryfunc am_await;
unaryfunc am_aiter;
unaryfunc am_anext;
} PyAsyncMethods;
typedef struct {
getbufferproc bf_getbuffer;
releasebufferproc bf_releasebuffer;
} PyBufferProcs;
/* from methodobject.h (the `PyObject **` are `PyObject *const *` in CPython) */
typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
typedef PyObject *(*_PyCFunctionFast) (PyObject *, PyObject **, Py_ssize_t);
typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
PyObject *);
typedef PyObject *(*_PyCFunctionFastWithKeywords) (PyObject *,
PyObject **, Py_ssize_t,
PyObject *);
typedef PyObject *(*PyNoArgsFunction)(PyObject *);
struct PyMethodDef {
const char *ml_name; /* The name of the built-in function/method */
PyCFunction ml_meth; /* The C function that implements it */
int ml_flags; /* Combination of METH_xxx flags, which mostly
describe the args expected by the C func */
const char *ml_doc; /* The __doc__ attribute, or NULL */
};
typedef struct PyMethodDef PyMethodDef;
typedef struct {
PyObject_HEAD
PyMethodDef *m_ml; /* Description of the C function to call */
PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */
PyObject *m_module; /* The __module__ attribute, can be anything */
PyObject *m_weakreflist; /* List of weak references */
} PyCFunctionObject;
/* from structmember.h */
typedef struct PyMemberDef {
/* Current version, use this */
const char *name;
int type;
Py_ssize_t offset;
int flags;
const char *doc;
} PyMemberDef;
typedef struct _typeobject {
PyObject_VAR_HEAD
const char *tp_name; /* For printing, in format "<module>.<name>" */
Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */
/* Methods to implement standard operations */
destructor tp_dealloc;
Py_ssize_t tp_vectorcall_offset;
getattrfunc tp_getattr;
setattrfunc tp_setattr;
PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2)
or tp_reserved (Python 3) */
reprfunc tp_repr;
/* Method suites for standard classes */
PyNumberMethods *tp_as_number;
PySequenceMethods *tp_as_sequence;
PyMappingMethods *tp_as_mapping;
/* More standard operations (here for binary compatibility) */
hashfunc tp_hash;
ternaryfunc tp_call;
reprfunc tp_str;
getattrofunc tp_getattro;
setattrofunc tp_setattro;
/* Functions to access object as input/output buffer */
PyBufferProcs *tp_as_buffer;
/* Flags to define presence of optional/expanded features */
unsigned long tp_flags;
const char *tp_doc; /* Documentation string */
/* Assigned meaning in release 2.0 */
/* call function for all accessible objects */
traverseproc tp_traverse;
/* delete references to contained objects */
inquiry tp_clear;
/* Assigned meaning in release 2.1 */
/* rich comparisons */
richcmpfunc tp_richcompare;
/* weak reference enabler */
Py_ssize_t tp_weaklistoffset;
/* Iterators */
getiterfunc tp_iter;
iternextfunc tp_iternext;
/* Attribute descriptor and subclassing stuff */
struct PyMethodDef *tp_methods;
struct PyMemberDef *tp_members;
struct PyGetSetDef *tp_getset;
struct _typeobject *tp_base;
PyObject *tp_dict;
descrgetfunc tp_descr_get;
descrsetfunc tp_descr_set;
Py_ssize_t tp_dictoffset;
initproc tp_init;
allocfunc tp_alloc;
newfunc tp_new;
freefunc tp_free; /* Low-level free-memory routine */
inquiry tp_is_gc; /* For PyObject_IS_GC */
PyObject *tp_bases;
PyObject *tp_mro; /* method resolution order */
PyObject *tp_cache;
PyObject *tp_subclasses;
PyObject *tp_weaklist;
destructor tp_del;
/* Type attribute cache version tag. Added in version 2.6 */
unsigned int tp_version_tag;
destructor tp_finalize;
vectorcallfunc tp_vectorcall;
printfunc tp_print; // deprecated, but stays around for compatibility
/* PyPy specific extra fields: make sure that they are ALWAYS at the end,
for compatibility with CPython */
long tp_pypy_flags;
} PyTypeObject;
typedef struct{
int slot; /* slot id, see below */
void *pfunc; /* function pointer */
} PyType_Slot;
typedef struct{
const char* name;
int basicsize;
int itemsize;
unsigned int flags;
PyType_Slot *slots; /* terminated by slot==0. */
} PyType_Spec;
typedef struct _heaptypeobject {
PyTypeObject ht_type;
PyAsyncMethods as_async;
PyNumberMethods as_number;
PyMappingMethods as_mapping;
PySequenceMethods as_sequence;
PyBufferProcs as_buffer;
PyObject *ht_name, *ht_slots, *ht_qualname;
PyObject *ht_module;
} PyHeapTypeObject;
/* access macro to the members which are floating "behind" the object */
#define PyHeapType_GET_MEMBERS(etype) \
((PyMemberDef *)(((char *)etype) + Py_TYPE(etype)->tp_basicsize))
typedef struct {
PyCFunctionObject func;
PyTypeObject *mm_class; /* Class that defines this method */
} PyCMethodObject;

View File

@ -0,0 +1,199 @@
/* --- Internal Unicode Format -------------------------------------------- */
/* Py_UNICODE was the native Unicode storage format (code unit) used by
Python and represents a single Unicode element in the Unicode type.
With PEP 393, Py_UNICODE is deprecated and replaced with a
typedef to wchar_t. */
#define PY_UNICODE_TYPE wchar_t
typedef wchar_t Py_UNICODE;
/* Py_UCS4 and Py_UCS2 are typedefs for the respective
unicode representations. */
typedef unsigned int Py_UCS4;
typedef unsigned short Py_UCS2;
typedef unsigned char Py_UCS1;
/* --- Unicode Type ------------------------------------------------------- */
typedef struct {
/*
SSTATE_NOT_INTERNED (0)
SSTATE_INTERNED_MORTAL (1)
SSTATE_INTERNED_IMMORTAL (2)
If interned != SSTATE_NOT_INTERNED, the two references from the
dictionary to this object are *not* counted in ob_refcnt.
*/
unsigned char interned;
/* Character size:
- PyUnicode_WCHAR_KIND (0):
* character type = wchar_t (16 or 32 bits, depending on the
platform)
- PyUnicode_1BYTE_KIND (1):
* character type = Py_UCS1 (8 bits, unsigned)
* all characters are in the range U+0000-U+00FF (latin1)
* if ascii is set, all characters are in the range U+0000-U+007F
(ASCII), otherwise at least one character is in the range
U+0080-U+00FF
- PyUnicode_2BYTE_KIND (2):
* character type = Py_UCS2 (16 bits, unsigned)
* all characters are in the range U+0000-U+FFFF (BMP)
* at least one character is in the range U+0100-U+FFFF
- PyUnicode_4BYTE_KIND (4):
* character type = Py_UCS4 (32 bits, unsigned)
* all characters are in the range U+0000-U+10FFFF
* at least one character is in the range U+10000-U+10FFFF
*/
unsigned char kind;
/* Compact is with respect to the allocation scheme. Compact unicode
objects only require one memory block while non-compact objects use
one block for the PyUnicodeObject struct and another for its data
buffer. */
unsigned char compact;
/* The string only contains characters in the range U+0000-U+007F (ASCII)
and the kind is PyUnicode_1BYTE_KIND. If ascii is set and compact is
set, use the PyASCIIObject structure. */
unsigned char ascii;
/* The ready flag indicates whether the object layout is initialized
completely. This means that this is either a compact object, or
the data pointer is filled out. The bit is redundant, and helps
to minimize the test in PyUnicode_IS_READY(). */
unsigned char ready;
/* Padding to ensure that PyUnicode_DATA() is always aligned to
4 bytes (see issue #19537 on m68k). */
/* not on PyPy */
} _PyASCIIObject_state_t;
/* ASCII-only strings created through PyUnicode_New use the PyASCIIObject
structure. state.ascii and state.compact are set, and the data
immediately follow the structure. utf8_length and wstr_length can be found
in the length field; the utf8 pointer is equal to the data pointer. */
typedef struct {
/* There are 4 forms of Unicode strings:
- compact ascii:
* structure = PyASCIIObject
* test: PyUnicode_IS_COMPACT_ASCII(op)
* kind = PyUnicode_1BYTE_KIND
* compact = 1
* ascii = 1
* ready = 1
* (length is the length of the utf8 and wstr strings)
* (data starts just after the structure)
* (since ASCII is decoded from UTF-8, the utf8 string are the data)
- compact:
* structure = PyCompactUnicodeObject
* test: PyUnicode_IS_COMPACT(op) && !PyUnicode_IS_ASCII(op)
* kind = PyUnicode_1BYTE_KIND, PyUnicode_2BYTE_KIND or
PyUnicode_4BYTE_KIND
* compact = 1
* ready = 1
* ascii = 0
* utf8 is not shared with data
* utf8_length = 0 if utf8 is NULL
* wstr is shared with data and wstr_length=length
if kind=PyUnicode_2BYTE_KIND and sizeof(wchar_t)=2
or if kind=PyUnicode_4BYTE_KIND and sizeof(wchar_t)=4
* wstr_length = 0 if wstr is NULL
* (data starts just after the structure)
- legacy string, not ready:
* structure = PyUnicodeObject
* test: kind == PyUnicode_WCHAR_KIND
* length = 0 (use wstr_length)
* hash = -1
* kind = PyUnicode_WCHAR_KIND
* compact = 0
* ascii = 0
* ready = 0
* interned = SSTATE_NOT_INTERNED
* wstr is not NULL
* data.any is NULL
* utf8 is NULL
* utf8_length = 0
- legacy string, ready:
* structure = PyUnicodeObject structure
* test: !PyUnicode_IS_COMPACT(op) && kind != PyUnicode_WCHAR_KIND
* kind = PyUnicode_1BYTE_KIND, PyUnicode_2BYTE_KIND or
PyUnicode_4BYTE_KIND
* compact = 0
* ready = 1
* data.any is not NULL
* utf8 is shared and utf8_length = length with data.any if ascii = 1
* utf8_length = 0 if utf8 is NULL
* wstr is shared with data.any and wstr_length = length
if kind=PyUnicode_2BYTE_KIND and sizeof(wchar_t)=2
or if kind=PyUnicode_4BYTE_KIND and sizeof(wchar_4)=4
* wstr_length = 0 if wstr is NULL
Compact strings use only one memory block (structure + characters),
whereas legacy strings use one block for the structure and one block
for characters.
Legacy strings are created by PyUnicode_FromUnicode() and
PyUnicode_FromStringAndSize(NULL, size) functions. They become ready
when PyUnicode_READY() is called.
See also _PyUnicode_CheckConsistency().
*/
PyObject_HEAD
Py_ssize_t length; /* Number of code points in the string */
//Py_hash_t hash; /* Hash value; -1 if not set */
_PyASCIIObject_state_t state;
wchar_t *wstr; /* wchar_t representation (null-terminated) */
} PyASCIIObject;
/* Non-ASCII strings allocated through PyUnicode_New use the
PyCompactUnicodeObject structure. state.compact is set, and the data
immediately follow the structure. */
typedef struct {
PyASCIIObject _base;
Py_ssize_t utf8_length; /* Number of bytes in utf8, excluding the
* terminating \0. */
char *utf8; /* UTF-8 representation (null-terminated) */
Py_ssize_t wstr_length; /* Number of code points in wstr, possible
* surrogates count as two code points. */
} PyCompactUnicodeObject;
/* Strings allocated through PyUnicode_FromUnicode(NULL, len) use the
PyUnicodeObject structure. The actual string data is initially in the wstr
block, and copied into the data block using _PyUnicode_Ready. */
typedef struct {
PyCompactUnicodeObject _base;
void* data; /* Canonical, smallest-form Unicode buffer */
} PyUnicodeObject;
/* --- Flexible String Representation Helper Macros (PEP 393) -------------- */
/* Values for PyASCIIObject.state: */
/* Interning state. */
#define SSTATE_NOT_INTERNED 0
#define SSTATE_INTERNED_MORTAL 1
#define SSTATE_INTERNED_IMMORTAL 2
/* --- Constants ---------------------------------------------------------- */
/* This Unicode character will be used as replacement character during
decoding if the errors argument is set to "replace". Note: the
Unicode character U+FFFD is the official REPLACEMENT CHARACTER in
Unicode 3.0. */
#define Py_UNICODE_REPLACEMENT_CHARACTER ((Py_UCS4) 0xFFFD)

View File

@ -0,0 +1,56 @@
#ifndef DATETIME_H
#define DATETIME_H
#ifdef __cplusplus
extern "C" {
#endif
#include "cpyext_datetime.h"
PyAPI_DATA(PyDateTime_CAPI*) PyDateTimeAPI;
#define PyDateTime_IMPORT (PyDateTimeAPI = _PyDateTime_Import())
/* Macro for access to the UTC singleton */
#define PyDateTime_TimeZone_UTC PyDateTimeAPI->TimeZone_UTC
/* Macros for accessing constructors in a simplified fashion. */
#define PyDate_FromDate(year, month, day) \
PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType)
#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \
PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, \
min, sec, usec, Py_None, PyDateTimeAPI->DateTimeType)
#define PyDateTime_FromDateAndTimeAndFold(year, month, day, hour, min, sec, usec, fold) \
PyDateTimeAPI->DateTime_FromDateAndTimeAndFold(year, month, day, hour, \
min, sec, usec, Py_None, fold, PyDateTimeAPI->DateTimeType)
#define PyTime_FromTime(hour, minute, second, usecond) \
PyDateTimeAPI->Time_FromTime(hour, minute, second, usecond, \
Py_None, PyDateTimeAPI->TimeType)
#define PyTime_FromTimeAndFold(hour, minute, second, usecond, fold) \
PyDateTimeAPI->Time_FromTimeAndFold(hour, minute, second, usecond, \
Py_None, fold, PyDateTimeAPI->TimeType)
#define PyDelta_FromDSU(days, seconds, useconds) \
PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \
PyDateTimeAPI->DeltaType)
#define PyTimeZone_FromOffset(offset) \
PyDateTimeAPI->TimeZone_FromTimeZone(offset, NULL)
#define PyTimeZone_FromOffsetAndName(offset, name) \
PyDateTimeAPI->TimeZone_FromTimeZone(offset, name)
#define PyDateTime_TimeZone_UTC PyDateTimeAPI->TimeZone_UTC
/* Issue 3627: PEP 495 defines PyDateTime_GET_FOLD but CPython implemented
* PyDateTime_DATE_GET_FOLD
*/
#define PyDateTime_DATE_GET_FOLD PyDateTime_GET_FOLD
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,6 @@
#ifndef Py_DESCROBJECT_H
#define Py_DESCROBJECT_H
#include "cpyext_descrobject.h"
#endif

View File

@ -0,0 +1,23 @@
/* dict object interface */
#ifndef Py_DICTOBJECT_H
#define Py_DICTOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PyObject_HEAD
PyObject *_tmpkeys; /* a private place to put keys during PyDict_Next */
} PyDictObject;
#define PyDict_Check(op) \
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS)
#define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
#define PyDict_GET_SIZE(op) PyObject_Length(op)
#ifdef __cplusplus
}
#endif
#endif /* !Py_DICTOBJECT_H */

View File

@ -0,0 +1,40 @@
/* Int object interface */
#ifndef Py_EVAL_H
#define Py_EVAL_H
#ifdef __cplusplus
extern "C" {
#endif
#include "Python.h"
#ifdef PY_SSIZE_T_CLEAN
#undef PyObject_CallFunction
#undef PyObject_CallMethod
#define PyObject_CallFunction _PyObject_CallFunction_SizeT
#define PyObject_CallMethod _PyObject_CallMethod_SizeT
#endif
#define PyEval_CallObject(func,arg) \
PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj, const char *format, ...);
PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj, const char *name, const char *format, ...);
PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *obj, const char *format, ...);
PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *obj, const char *name, const char *format, ...);
PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *obj, const char *format, ...);
PyAPI_FUNC(PyObject *) _PyObject_CallMethod_SizeT(PyObject *obj, const char *name, const char *format, ...);
PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable, ...);
PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(PyObject *callable, PyObject *name, ...);
/* These constants are also defined in cpyext/eval.py */
#define Py_single_input 256
#define Py_file_input 257
#define Py_eval_input 258
#define Py_func_type_input 345
#ifdef __cplusplus
}
#endif
#endif /* !Py_EVAL_H */

View File

@ -0,0 +1,30 @@
#ifndef Py_EXPORTS_H
#define Py_EXPORTS_H
#if defined(_WIN32) || defined(__CYGWIN__)
#define Py_IMPORTED_SYMBOL __declspec(dllimport)
#define Py_EXPORTED_SYMBOL __declspec(dllexport)
#define Py_LOCAL_SYMBOL
#else
/*
* If we only ever used gcc >= 5, we could use __has_attribute(visibility)
* as a cross-platform way to determine if visibility is supported. However,
* we may still need to support gcc >= 4, as some Ubuntu LTS and Centos versions
* have 4 < gcc < 5.
*/
#ifndef __has_attribute
#define __has_attribute(x) 0 // Compatibility with non-clang compilers.
#endif
#if (defined(__GNUC__) && (__GNUC__ >= 4)) ||\
(defined(__clang__) && __has_attribute(visibility))
#define Py_IMPORTED_SYMBOL __attribute__ ((visibility ("default")))
#define Py_EXPORTED_SYMBOL __attribute__ ((visibility ("default")))
#define Py_LOCAL_SYMBOL __attribute__ ((visibility ("hidden")))
#else
#define Py_IMPORTED_SYMBOL
#define Py_EXPORTED_SYMBOL
#define Py_LOCAL_SYMBOL
#endif
#endif
#endif /* Py_EXPORTS_H */

View File

@ -0,0 +1,2 @@
PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
PyAPI_FUNC(void) _Py_setfilesystemdefaultencoding(const char *);

View File

@ -0,0 +1,42 @@
/* Float object interface */
#ifndef Py_FLOATOBJECT_H
#define Py_FLOATOBJECT_H
#ifdef _MSC_VER
#include <math.h>
#include <float.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PyObject_HEAD
double ob_fval;
} PyFloatObject;
#define PyFloat_STR_PRECISION 12
#ifdef Py_NAN
#define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN)
#endif
#define Py_RETURN_INF(sign) do \
if (copysign(1., sign) == 1.) { \
return PyFloat_FromDouble(Py_HUGE_VAL); \
} else { \
return PyFloat_FromDouble(-Py_HUGE_VAL); \
} while(0)
#define PyFloat_Check(op) \
_PyPy_Type_FastSubclass(Py_TYPE(op), Py_TPPYPYFLAGS_FLOAT_SUBCLASS)
#define PyFloat_CheckExact(op) (Py_TYPE(op) == &PyFloat_Type)
#ifdef __cplusplus
}
#endif
#endif /* !Py_FLOATOBJECT_H */

View File

@ -0,0 +1,19 @@
#ifndef Py_FRAMEOBJECT_H
#define Py_FRAMEOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _frame {
PyObject_HEAD
struct _frame *f_back; /* previous frame, or NULL */
PyCodeObject *f_code;
PyObject *f_globals;
PyObject *f_locals;
int f_lineno;
} PyFrameObject;
#ifdef __cplusplus
}
#endif
#endif /* !Py_FRAMEOBJECT_H */

View File

@ -0,0 +1,23 @@
/* Function object interface */
#ifndef Py_FUNCOBJECT_H
#define Py_FUNCOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PyObject_HEAD
PyObject *func_name; /* The __name__ attribute, a string object */
} PyFunctionObject;
#define PyFunction_GET_CODE(obj) PyFunction_GetCode((PyObject*)(obj))
#define PyMethod_GET_FUNCTION(obj) PyMethod_Function((PyObject*)(obj))
#define PyMethod_GET_SELF(obj) PyMethod_Self((PyObject*)(obj))
#ifdef __cplusplus
}
#endif
#endif /* !Py_FUNCOBJECT_H */

View File

@ -0,0 +1,12 @@
#ifndef Py_GENERICALIASOBJECT_H
#define Py_GENERICALIASOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
#define Py_GenericAlias PyPy_GenericAlias
PyAPI_FUNC(struct _object *) Py_GenericAlias(struct _object *arg0, struct _object *arg1);
#ifdef __cplusplus
}
#endif
#endif /* !Py_GENERICALIASOBJECT_H */

View File

@ -0,0 +1,12 @@
#ifndef Py_GENOBJECT_H
#define Py_GENOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
#include "cpyext_genobject.h"
#ifdef __cplusplus
}
#endif
#endif /* !Py_GENOBJECT_H */

View File

@ -0,0 +1,94 @@
/* Generated from pypy.interpreter.pyparser.pygram.syms */
#define and_expr 257
#define and_test 258
#define annassign 259
#define arglist 260
#define argument 261
#define arith_expr 262
#define assert_stmt 263
#define async_funcdef 264
#define async_stmt 265
#define atom 266
#define atom_expr 267
#define augassign 268
#define break_stmt 269
#define classdef 270
#define comp_for 271
#define comp_if 272
#define comp_iter 273
#define comp_op 274
#define comparison 275
#define compound_stmt 276
#define continue_stmt 277
#define decorated 278
#define decorator 279
#define decorators 280
#define del_stmt 281
#define dictorsetmaker 282
#define dotted_as_name 283
#define dotted_as_names 284
#define dotted_name 285
#define encoding_decl 286
#define eval_input 287
#define except_clause 288
#define expr 289
#define expr_stmt 290
#define exprlist 291
#define factor 292
#define file_input 293
#define flow_stmt 294
#define for_stmt 295
#define func_body_suite 296
#define func_type 297
#define func_type_input 298
#define funcdef 299
#define global_stmt 300
#define if_stmt 301
#define import_as_name 302
#define import_as_names 303
#define import_from 304
#define import_name 305
#define import_stmt 306
#define lambdef 307
#define lambdef_nocond 308
#define namedexpr_test 309
#define nonlocal_stmt 310
#define not_test 311
#define or_test 312
#define parameters 313
#define pass_stmt 314
#define power 315
#define raise_stmt 316
#define return_stmt 317
#define shift_expr 318
#define simple_stmt 319
#define single_input 256
#define sliceop 320
#define small_stmt 321
#define star_expr 322
#define stmt 323
#define subscript 324
#define subscriptlist 325
#define suite 326
#define sync_comp_for 327
#define term 328
#define test 329
#define test_nocond 330
#define testlist 331
#define testlist_comp 332
#define testlist_star_expr 333
#define tfpdef 334
#define trailer 335
#define try_stmt 336
#define typedargslist 337
#define typelist 338
#define varargslist 339
#define vfpdef 340
#define while_stmt 341
#define with_item 342
#define with_stmt 343
#define xor_expr 344
#define yield_arg 345
#define yield_expr 346
#define yield_stmt 347

View File

@ -0,0 +1,24 @@
/* Module definition and import interface */
#ifndef Py_IMPORT_H
#define Py_IMPORT_H
#ifdef __cplusplus
extern "C" {
#endif
PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(
const char *name, /* UTF-8 encoded string */
PyObject *globals,
PyObject *locals,
PyObject *fromlist,
int level
);
#define PyImport_ImportModuleEx(n, g, l, f) \
PyImport_ImportModuleLevel(n, g, l, f, 0)
#ifdef __cplusplus
}
#endif
#endif /* !Py_IMPORT_H */

View File

@ -0,0 +1,4 @@
/* empty */
#define PyList_Check(op) \
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS)
#define PyList_CheckExact(op) (Py_TYPE(op) == &PyList_Type)

View File

@ -0,0 +1 @@
/* empty */

View File

@ -0,0 +1,29 @@
#ifndef Py_LONGOBJECT_H
#define Py_LONGOBJECT_H
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/* why does cpython redefine these, and even supply an implementation in mystrtoul.c?
PyAPI_FUNC(unsigned long) PyOS_strtoul(const char *, char **, int);
PyAPI_FUNC(long) PyOS_strtol(const char *, char **, int);
*/
#define PyOS_strtoul strtoul
#define PyOS_strtol strtoul
#define PyLong_Check(op) \
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS)
#define PyLong_CheckExact(op) (Py_TYPE(op) == &PyLong_Type)
#define PyLong_AS_LONG(op) PyLong_AsLong(op)
#define _PyLong_AsByteArray(v, bytes, n, little_endian, is_signed) \
_PyLong_AsByteArrayO((PyObject *)(v), bytes, n, little_endian, is_signed)
#ifdef __cplusplus
}
#endif
#endif /* !Py_LONGOBJECT_H */

View File

@ -0,0 +1,13 @@
#ifndef Py_MARSHAL_H
#define Py_MARSHAL_H
#ifdef __cplusplus
extern "C" {
#endif
#define Py_MARSHAL_VERSION 2
#include "pypy_marshal_decl.h"
#ifdef __cplusplus
}
#endif
#endif /* !Py_MARSHAL_H */

View File

@ -0,0 +1,19 @@
#ifndef Py_MEMORYOBJECT_H
#define Py_MEMORYOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
#include "cpyext_memoryobject.h"
/* Get a pointer to the memoryview's private copy of the exporter's buffer. */
#define PyMemoryView_GET_BUFFER(op) (&((PyMemoryViewObject *)(op))->view)
/* Get a pointer to the exporting object (this may be NULL!). */
#define PyMemoryView_GET_BASE(op) (((PyMemoryViewObject *)(op))->view.obj)
#ifdef __cplusplus
}
#endif
#endif /* !Py_MEMORYOBJECT_H */

View File

@ -0,0 +1,66 @@
/* Method object interface */
#ifndef Py_METHODOBJECT_H
#define Py_METHODOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Flag passed to newmethodobject */
#define METH_VARARGS 0x0001
#define METH_KEYWORDS 0x0002
/* METH_NOARGS and METH_O must not be combined with the flags above. */
#define METH_NOARGS 0x0004
#define METH_O 0x0008
/* METH_CLASS and METH_STATIC are a little different; these control
the construction of methods for a class. These cannot be used for
functions in modules. */
#define METH_CLASS 0x0010
#define METH_STATIC 0x0020
/* METH_COEXIST allows a method to be entered eventhough a slot has
already filled the entry. When defined, the flag allows a separate
method, "__contains__" for example, to coexist with a defined
slot like sq_contains. */
#define METH_COEXIST 0x0040
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03100000
#define METH_FASTCALL 0x0080
#endif
/* METH_METHOD means the function stores an
* additional reference to the class that defines it;
* both self and class are passed to it.
* It uses PyCMethodObject instead of PyCFunctionObject.
* May not be combined with METH_NOARGS, METH_O, METH_CLASS or METH_STATIC.
*/
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
#define METH_METHOD 0x0200
#endif
#define PyCFunction_New(ml, self) PyCFunction_NewEx((ml), (self), NULL)
#define PyCFunction_NewEx(ML, SELF, MOD) PyCMethod_New((ML), (SELF), (MOD), NULL)
/* Macros for direct access to these values. Type checks are *not*
done, so use with care. */
#define PyCFunction_GET_FUNCTION(func) \
(((PyCFunctionObject *)func) -> m_ml -> ml_meth)
#define PyCFunction_GET_SELF(func) \
(((PyCFunctionObject *)func) -> m_ml -> ml_flags & METH_STATIC ? \
NULL : ((PyCFunctionObject *)func) -> m_self)
#define PyCFunction_GET_FLAGS(func) \
(((PyCFunctionObject *)func) -> m_ml -> ml_flags)
#define PyCFunction_GET_CLASS(func) \
(((PyCFunctionObject *)func) -> m_ml -> ml_flags & METH_METHOD ? \
((PyCMethodObject *)func) -> mm_class : NULL)
#ifdef __cplusplus
}
#endif
#endif /* !Py_METHODOBJECT_H */

View File

@ -0,0 +1,14 @@
/* Definitions from missing header files */
#ifndef Py_MISSING_H
#define Py_MISSING_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* !Py_MISSING_H */

View File

@ -0,0 +1,196 @@
#ifndef Py_MODSUPPORT_H
#define Py_MODSUPPORT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Module support interface */
#include <stdarg.h>
/* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier
to mean Py_ssize_t */
#ifdef PY_SSIZE_T_CLEAN
#undef PyArg_Parse
#undef PyArg_ParseTuple
#undef PyArg_ParseTupleAndKeywords
#undef PyArg_VaParse
#undef PyArg_VaParseTupleAndKeywords
#undef Py_BuildValue
#undef Py_VaBuildValue
#define PyArg_Parse _PyArg_Parse_SizeT
#define PyArg_ParseTuple _PyArg_ParseTuple_SizeT
#define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT
#define PyArg_VaParse _PyArg_VaParse_SizeT
#define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT
#define Py_BuildValue _Py_BuildValue_SizeT
#define Py_VaBuildValue _Py_VaBuildValue_SizeT
#ifndef Py_LIMITED_API
#define _Py_VaBuildStack _Py_VaBuildStack_SizeT
#endif
#else
#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list);
PyAPI_FUNC(PyObject **) _Py_VaBuildStack_SizeT(
PyObject **small_stack,
Py_ssize_t small_stack_len,
const char *format,
va_list va,
Py_ssize_t *p_nargs);
#endif /* !Py_LIMITED_API */
#endif
/* Due to a glitch in 3.2, the _SizeT versions weren't exported from the DLL. */
#if !defined(PY_SSIZE_T_CLEAN) || !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);
PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...);
PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
const char *, char **, ...);
PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list);
PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
const char *, char **, va_list);
#endif
PyAPI_FUNC(int) PyArg_ValidateKeywordArguments(PyObject *);
PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...);
PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...);
PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
#ifndef Py_LIMITED_API
PyAPI_FUNC(int) _PyArg_UnpackStack(
PyObject *const *args,
Py_ssize_t nargs,
const char *name,
Py_ssize_t min,
Py_ssize_t max,
...);
#undef _PyArg_NoKeywords
PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kwargs);
PyAPI_FUNC(int) _PyArg_NoKwnames(const char *funcname, PyObject *kwnames);
PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args);
#define _PyArg_NoKeywords(funcname, kwargs) \
((kwargs) == NULL || _PyArg_NoKeywords((funcname), (kwargs)))
#define _PyArg_NoKwnames(funcname, kwnames) \
((kwnames) == NULL || _PyArg_NoKwnames((funcname), (kwnames)))
#define _PyArg_NoPositional(funcname, args) \
((args) == NULL || _PyArg_NoPositional((funcname), (args)))
PyAPI_FUNC(void) _PyArg_BadArgument(const char *, const char *, const char *, PyObject *);
PyAPI_FUNC(int) _PyArg_CheckPositional(const char *, Py_ssize_t,
Py_ssize_t, Py_ssize_t);
#define _PyArg_CheckPositional(funcname, nargs, min, max) \
(((min) <= (nargs) && (nargs) <= (max)) \
|| _PyArg_CheckPositional((funcname), (nargs), (min), (max)))
#endif
PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list);
#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject **) _Py_VaBuildStack(
PyObject **small_stack,
Py_ssize_t small_stack_len,
const char *format,
va_list va,
Py_ssize_t *p_nargs);
#endif
#ifndef Py_LIMITED_API
typedef struct _PyArg_Parser {
const char *format;
const char * const *keywords;
const char *fname;
const char *custom_msg;
int pos; /* number of positional-only arguments */
int min; /* minimal number of arguments */
int max; /* maximal number of positional arguments */
PyObject *kwtuple; /* tuple of keyword parameter names */
struct _PyArg_Parser *next;
} _PyArg_Parser;
#ifdef PY_SSIZE_T_CLEAN
#define _PyArg_ParseTupleAndKeywordsFast _PyArg_ParseTupleAndKeywordsFast_SizeT
#define _PyArg_ParseStack _PyArg_ParseStack_SizeT
#define _PyArg_ParseStackAndKeywords _PyArg_ParseStackAndKeywords_SizeT
#define _PyArg_VaParseTupleAndKeywordsFast _PyArg_VaParseTupleAndKeywordsFast_SizeT
#endif
PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *,
struct _PyArg_Parser *, ...);
PyAPI_FUNC(int) _PyArg_ParseStack(
PyObject *const *args,
Py_ssize_t nargs,
const char *format,
...);
PyAPI_FUNC(int) _PyArg_ParseStackAndKeywords(
PyObject *const *args,
Py_ssize_t nargs,
PyObject *kwnames,
struct _PyArg_Parser *,
...);
PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywordsFast(PyObject *, PyObject *,
struct _PyArg_Parser *, va_list);
PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords(
PyObject *const *args, Py_ssize_t nargs,
PyObject *kwargs, PyObject *kwnames,
struct _PyArg_Parser *parser,
int minpos, int maxpos, int minkw,
PyObject **buf);
#define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \
(((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \
(minpos) <= (nargs) && (nargs) <= (maxpos) && args != NULL) ? (args) : \
_PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \
(minpos), (maxpos), (minkw), (buf)))
void _PyArg_Fini(void);
#endif /* Py_LIMITED_API */
PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *);
PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long);
PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *);
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
/* New in 3.9 */
PyAPI_FUNC(int) PyModule_AddType(PyObject *module, PyTypeObject *type);
#endif /* Py_LIMITED_API */
#define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
#define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant(m, #c, c)
#define Py_CLEANUP_SUPPORTED 0x20000
#define PYTHON_API_VERSION 1013
#define PYTHON_API_STRING "1013"
/* The PYTHON_ABI_VERSION is introduced in PEP 384. For the lifetime of
Python 3, it will stay at the value of 3; changes to the limited API
must be performed in a strictly backwards-compatible manner. */
#define PYTHON_ABI_VERSION 3
#define PYTHON_ABI_STRING "3"
PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, const char *, ...);
PyAPI_FUNC(int) _PyArg_ParseTuple_SizeT(PyObject *, const char *, ...);
PyAPI_FUNC(int) _PyArg_VaParse_SizeT(PyObject *, const char *, va_list);
PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
const char *, char **, ...);
PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
const char *, char **, va_list);
PyAPI_FUNC(PyObject *) PyModule_Create2(struct PyModuleDef*,
int apiver);
#ifdef Py_LIMITED_API
#define PyModule_Create(module) \
PyModule_Create2(module, PYTHON_ABI_VERSION)
#else
#define PyModule_Create(module) \
PyModule_Create2(module, PYTHON_API_VERSION)
#endif
#ifndef Py_LIMITED_API
PyAPI_DATA(const char *) _Py_PackageContext;
#endif
#ifdef __cplusplus
}
#endif
#endif /* !Py_MODSUPPORT_H */

View File

@ -0,0 +1,20 @@
/* Module object interface */
#ifndef Py_MODULEOBJECT_H
#define Py_MODULEOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
#include "cpyext_moduleobject.h"
PyAPI_FUNC(struct PyModuleDef*) PyModule_GetDef(PyObject*);
PyAPI_FUNC(void*) PyModule_GetState(PyObject*);
PyAPI_FUNC(PyObject *) PyModuleDef_Init(struct PyModuleDef*);
#ifdef __cplusplus
}
#endif
#endif /* !Py_MODULEOBJECT_H */

View File

@ -0,0 +1,477 @@
#ifndef Py_OBJECT_H
#define Py_OBJECT_H
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "cpyext_object.h"
#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
/*
CPython has this for backwards compatibility with really old extensions, and now
we have it for compatibility with CPython.
*/
#define staticforward static
#define PyObject_HEAD_INIT(type) \
{ 1, 0, type },
#define PyVarObject_HEAD_INIT(type, size) \
{ PyObject_HEAD_INIT(type) size },
/* Cast argument to PyVarObject* type. */
#define _PyVarObject_CAST(op) ((PyVarObject*)(op))
/* Cast argument to PyObject* type. */
#define _PyObject_CAST(op) ((PyObject*)(op))
#define _PyObject_CAST_CONST(op) ((const PyObject*)(op))
#define Py_REFCNT(ob) (_PyObject_CAST(ob)->ob_refcnt)
#define Py_TYPE(ob) (_PyObject_CAST(ob)->ob_type)
#define Py_SIZE(ob) (_PyVarObject_CAST(ob)->ob_size)
static inline int _Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type) {
return ob->ob_type == type;
}
#define Py_IS_TYPE(ob, type) _Py_IS_TYPE(_PyObject_CAST_CONST(ob), type)
static inline void _Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) {
ob->ob_refcnt = refcnt;
}
#define Py_SET_REFCNT(ob, refcnt) _Py_SET_REFCNT(_PyObject_CAST(ob), refcnt)
static inline void _Py_SET_TYPE(PyObject *ob, PyTypeObject *type) {
ob->ob_type = type;
}
#define Py_SET_TYPE(ob, type) _Py_SET_TYPE(_PyObject_CAST(ob), type)
static inline void _Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size) {
ob->ob_size = size;
}
#define Py_SET_SIZE(ob, size) _Py_SET_SIZE(_PyVarObject_CAST(ob), size)
PyAPI_FUNC(void) _Py_Dealloc(PyObject *);
#ifdef PYPY_DEBUG_REFCOUNT
/* Slow version, but useful for debugging */
#define Py_INCREF(ob) (Py_IncRef((PyObject *)(ob)))
#define Py_DECREF(ob) (Py_DecRef((PyObject *)(ob)))
#define Py_XINCREF(ob) (Py_IncRef((PyObject *)(ob)))
#define Py_XDECREF(ob) (Py_DecRef((PyObject *)(ob)))
#else
/* Fast version */
static inline void _Py_INCREF(PyObject *op)
{
op->ob_refcnt++;
}
#define Py_INCREF(op) _Py_INCREF(_PyObject_CAST(op))
static inline void _Py_DECREF(PyObject *op)
{
if (--op->ob_refcnt != 0) {
}
else {
_Py_Dealloc(op);
}
}
#define Py_DECREF(op) _Py_DECREF(_PyObject_CAST(op))
/* Function to use in case the object pointer can be NULL: */
static inline void _Py_XINCREF(PyObject *op)
{
if (op != NULL) {
Py_INCREF(op);
}
}
#define Py_XINCREF(op) _Py_XINCREF(_PyObject_CAST(op))
static inline void _Py_XDECREF(PyObject *op)
{
if (op != NULL) {
Py_DECREF(op);
}
}
#define Py_XDECREF(op) _Py_XDECREF(_PyObject_CAST(op))
PyAPI_FUNC(void) Py_IncRef(PyObject *);
PyAPI_FUNC(void) Py_DecRef(PyObject *);
extern void *_pypy_rawrefcount_w_marker_deallocating;
#define Py_CLEAR(op) \
do { \
PyObject *_py_tmp = _PyObject_CAST(op); \
if (_py_tmp != NULL) { \
(op) = NULL; \
Py_DECREF(_py_tmp); \
} \
} while (0)
#endif
#ifndef Py_LIMITED_API
#define Py_SETREF(op, op2) \
do { \
PyObject *_py_tmp = _PyObject_CAST(op); \
(op) = (op2); \
Py_DECREF(_py_tmp); \
} while (0)
#define Py_XSETREF(op, op2) \
do { \
PyObject *_py_tmp = _PyObject_CAST(op); \
(op) = (op2); \
Py_XDECREF(_py_tmp); \
} while (0)
#define _Py_NewReference(op) \
( ((PyObject *)(op))->ob_refcnt = 1, \
((PyObject *)(op))->ob_pypy_link = 0 )
#define _Py_ForgetReference(ob) /* nothing */
#endif
#define Py_None (&_Py_NoneStruct)
/* Macro for returning Py_None from a function */
#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
/*
Py_NotImplemented is a singleton used to signal that an operation is
not implemented for a given type combination.
*/
#define Py_NotImplemented (&_Py_NotImplementedStruct)
/* Macro for returning Py_NotImplemented from a function */
#define Py_RETURN_NOTIMPLEMENTED \
return Py_INCREF(Py_NotImplemented), Py_NotImplemented
/* Rich comparison opcodes */
/*
XXX: Also defined in slotdefs.py
*/
#define Py_LT 0
#define Py_LE 1
#define Py_EQ 2
#define Py_NE 3
#define Py_GT 4
#define Py_GE 5
/* Py3k buffer interface, adapted for PyPy */
/* Flags for getting buffers */
#define PyBUF_SIMPLE 0
#define PyBUF_WRITABLE 0x0001
/* we used to include an E, backwards compatible alias */
#define PyBUF_WRITEABLE PyBUF_WRITABLE
#define PyBUF_FORMAT 0x0004
#define PyBUF_ND 0x0008
#define PyBUF_STRIDES (0x0010 | PyBUF_ND)
#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
#define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE)
#define PyBUF_CONTIG_RO (PyBUF_ND)
#define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE)
#define PyBUF_STRIDED_RO (PyBUF_STRIDES)
#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT)
#define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT)
#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT)
#define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT)
#define PyBUF_READ 0x100
#define PyBUF_WRITE 0x200
#define PyBUF_SHADOW 0x400
/* end Py3k buffer interface */
PyAPI_FUNC(PyObject*) PyType_FromSpec(PyType_Spec*);
PyAPI_FUNC(PyObject *) PyType_GetModule(struct _typeobject *);
PyAPI_FUNC(void *) PyType_GetModuleState(struct _typeobject *);
/* Flag bits for printing: */
#define Py_PRINT_RAW 1 /* No string quotes etc. */
/*
`Type flags (tp_flags)
These flags are used to extend the type structure in a backwards-compatible
fashion. Extensions can use the flags to indicate (and test) when a given
type structure contains a new feature. The Python core will use these when
introducing new functionality between major revisions (to avoid mid-version
changes in the PYTHON_API_VERSION).
Arbitration of the flag bit positions will need to be coordinated among
all extension writers who publically release their extensions (this will
be fewer than you might expect!)..
Most flags were removed as of Python 3.0 to make room for new flags. (Some
flags are not for backwards compatibility but to indicate the presence of an
optional feature; these flags remain of course.)
Type definitions should use Py_TPFLAGS_DEFAULT for their tp_flags value.
Code can use PyType_HasFeature(type_ob, flag_value) to test whether the
given type object has a specified feature.
*/
/* Set if the type object is dynamically allocated */
#define Py_TPFLAGS_HEAPTYPE (1L<<9)
/* Set if the type allows subclassing */
#define Py_TPFLAGS_BASETYPE (1L<<10)
/* Set if the type implements the vectorcall protocol (PEP 590) */
#define Py_TPFLAGS_HAVE_VECTORCALL (1UL << 11)
// Backwards compatibility alias for API that was provisional in Python 3.8
#define _Py_TPFLAGS_HAVE_VECTORCALL Py_TPFLAGS_HAVE_VECTORCALL
/* Set if the type is 'ready' -- fully initialized */
#define Py_TPFLAGS_READY (1L<<12)
/* Set while the type is being 'readied', to prevent recursive ready calls */
#define Py_TPFLAGS_READYING (1L<<13)
/* Objects support garbage collection (see objimp.h) */
#define Py_TPFLAGS_HAVE_GC (1L<<14)
/* These two bits are preserved for Stackless Python, next after this is 17 */
#ifdef STACKLESS
#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION (3L<<15)
#else
#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0
#endif
/* Objects behave like an unbound method */
#define Py_TPFLAGS_METHOD_DESCRIPTOR (1UL << 17)
/* Objects support type attribute cache */
#define Py_TPFLAGS_HAVE_VERSION_TAG (1L<<18)
#define Py_TPFLAGS_VALID_VERSION_TAG (1L<<19)
/* Type is abstract and cannot be instantiated */
#define Py_TPFLAGS_IS_ABSTRACT (1L<<20)
/* These flags are used to determine if a type is a subclass. */
#define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24)
#define Py_TPFLAGS_LIST_SUBCLASS (1UL << 25)
#define Py_TPFLAGS_TUPLE_SUBCLASS (1UL << 26)
#define Py_TPFLAGS_BYTES_SUBCLASS (1UL << 27)
#define Py_TPFLAGS_UNICODE_SUBCLASS (1UL << 28)
#define Py_TPFLAGS_DICT_SUBCLASS (1UL << 29)
#define Py_TPFLAGS_BASE_EXC_SUBCLASS (1UL << 30)
#define Py_TPFLAGS_TYPE_SUBCLASS (1UL << 31)
/* These are conceptually the same as the flags above, but they are
PyPy-specific and are stored inside tp_pypy_flags */
#define Py_TPPYPYFLAGS_FLOAT_SUBCLASS (1L<<0)
#define Py_TPFLAGS_DEFAULT ( \
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \
Py_TPFLAGS_HAVE_VERSION_TAG | \
0)
/* NOTE: The following flags reuse lower bits (removed as part of the
* Python 3.0 transition). */
/* Type structure has tp_finalize member (3.4) */
#define Py_TPFLAGS_HAVE_FINALIZE (1UL << 0)
PyAPI_FUNC(long) PyType_GetFlags(PyTypeObject*);
#ifdef Py_LIMITED_API
#define PyType_HasFeature(t,f) ((PyType_GetFlags(t) & (f)) != 0)
#else
#define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0)
#endif
#define PyType_FastSubclass(t,f) PyType_HasFeature(t,f)
#define _PyPy_Type_FastSubclass(t,f) (((t)->tp_pypy_flags & (f)) != 0)
#if !defined(Py_LIMITED_API)
PyAPI_FUNC(void*) PyType_GetSlot(PyTypeObject*, int);
#endif
#define PyType_Check(op) \
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS)
#define PyType_CheckExact(op) (Py_TYPE(op) == &PyType_Type)
PyAPI_FUNC(const char *) _PyType_Name(PyTypeObject *);
/* objimpl.h ----------------------------------------------*/
#define PyObject_New(type, typeobj) \
( (type *) _PyObject_New(typeobj) )
#define PyObject_NewVar(type, typeobj, n) \
( (type *) _PyObject_NewVar((typeobj), (n)) )
#define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize )
#define _PyObject_VAR_SIZE(typeobj, nitems) \
(size_t) \
( ( (typeobj)->tp_basicsize + \
(nitems)*(typeobj)->tp_itemsize + \
(SIZEOF_VOID_P - 1) \
) & ~(SIZEOF_VOID_P - 1) \
)
#define PyObject_INIT(op, typeobj) \
( Py_TYPE(op) = (typeobj), ((PyObject *)(op))->ob_refcnt = 1,\
((PyObject *)(op))->ob_pypy_link = 0, (op) )
#define PyObject_INIT_VAR(op, typeobj, size) \
( Py_SIZE(op) = (size), PyObject_INIT((op), (typeobj)) )
PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t);
/*
#define PyObject_NEW(type, typeobj) \
( (type *) PyObject_Init( \
(PyObject *) PyObject_MALLOC( _PyObject_SIZE(typeobj) ), (typeobj)) )
*/
#define PyObject_NEW PyObject_New
#define PyObject_NEW_VAR PyObject_NewVar
/*
#define PyObject_NEW_VAR(type, typeobj, n) \
( (type *) PyObject_InitVar( \
(PyVarObject *) PyObject_MALLOC(_PyObject_VAR_SIZE((typeobj),(n)) ),\
(typeobj), (n)) )
*/
#define PyObject_GC_New(type, typeobj) \
( (type *) _PyObject_GC_New(typeobj) )
#define PyObject_GC_NewVar(type, typeobj, size) \
( (type *) _PyObject_GC_NewVar(typeobj, size) )
/* A dummy PyGC_Head, just to please some tests. Don't use it! */
typedef union _gc_head {
char dummy;
} PyGC_Head;
/* dummy GC macros */
#define _PyGC_FINALIZED(o) 1
#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC)
#define PyObject_GC_Track(o) do { } while(0)
#define PyObject_GC_UnTrack(o) do { } while(0)
#define _PyObject_GC_TRACK(o) do { } while(0)
#define _PyObject_GC_UNTRACK(o) do { } while(0)
/* Utility macro to help write tp_traverse functions.
* To use this macro, the tp_traverse function must name its arguments
* "visit" and "arg". This is intended to keep tp_traverse functions
* looking as much alike as possible.
*/
#define Py_VISIT(op) \
do { \
if (op) { \
int vret = visit((PyObject *)(op), arg); \
if (vret) \
return vret; \
} \
} while (0)
#define PyObject_TypeCheck(ob, tp) \
(Py_TYPE(ob) == (tp) || PyType_IsSubtype(Py_TYPE(ob), (tp)))
#define Py_TRASHCAN_SAFE_BEGIN(pyObj) do {
#define Py_TRASHCAN_SAFE_END(pyObj) ; } while(0);
/* note: the ";" at the start of Py_TRASHCAN_SAFE_END is needed
if the code has a label in front of the macro call */
/* Copied from CPython ----------------------------- */
PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *, const void **, Py_ssize_t *);
PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *, void **, Py_ssize_t *);
PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *);
PyAPI_FUNC(void *) PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices);
/* Get the memory area pointed to by the indices for the buffer given.
Note that view->ndim is the assumed size of indices
*/
PyAPI_FUNC(int) PyBuffer_ToContiguous(void *buf, Py_buffer *view,
Py_ssize_t len, char fort);
PyAPI_FUNC(int) PyBuffer_FromContiguous(Py_buffer *view, void *buf,
Py_ssize_t len, char fort);
/* Copy len bytes of data from the contiguous chunk of memory
pointed to by buf into the buffer exported by obj. Return
0 on success and return -1 and raise a PyBuffer_Error on
error (i.e. the object does not have a buffer interface or
it is not working).
If fort is 'F' and the object is multi-dimensional,
then the data will be copied into the array in
Fortran-style (first dimension varies the fastest). If
fort is 'C', then the data will be copied into the array
in C-style (last dimension varies the fastest). If fort
is 'A', then it does not matter and the copy will be made
in whatever way is more efficient.
*/
/* on CPython, these are in objimpl.h */
PyAPI_FUNC(void) PyObject_Free(void *);
PyAPI_FUNC(void) PyObject_GC_Del(void *);
#define PyObject_MALLOC PyObject_Malloc
#define PyObject_REALLOC PyObject_Realloc
#define PyObject_FREE PyObject_Free
#define PyObject_Del PyObject_Free
#define PyObject_DEL PyObject_Free
PyAPI_FUNC(PyObject *) _PyObject_New(PyTypeObject *);
PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t);
PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *);
PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t);
PyAPI_FUNC(PyObject *) PyObject_Init(PyObject *, PyTypeObject *);
PyAPI_FUNC(PyVarObject *) PyObject_InitVar(PyVarObject *,
PyTypeObject *, Py_ssize_t);
#ifndef Py_LIMITED_API
PyAPI_FUNC(int) PyObject_CallFinalizerFromDealloc(PyObject *);
#endif
/*
* On CPython with Py_REF_DEBUG these use _PyRefTotal, _Py_NegativeRefcount,
* _Py_GetRefTotal, ...
* So far we ignore Py_REF_DEBUG
*/
#define _Py_INC_REFTOTAL
#define _Py_DEC_REFTOTAL
#define _Py_REF_DEBUG_COMMA
#define _Py_CHECK_REFCNT(OP) /* a semicolon */;
/* PyPy internal ----------------------------------- */
PyAPI_FUNC(int) PyPyType_Register(PyTypeObject *);
#define PyObject_Length PyObject_Size
#define _PyObject_GC_Del PyObject_GC_Del
PyAPI_FUNC(void) _PyPy_subtype_dealloc(PyObject *);
PyAPI_FUNC(void) _PyPy_object_dealloc(PyObject *);
#ifdef __cplusplus
}
#endif
#endif /* !Py_OBJECT_H */

View File

@ -0,0 +1,53 @@
/* Newfangled version identification scheme.
This scheme was added in Python 1.5.2b2; before that time, only PATCHLEVEL
was available. To test for presence of the scheme, test for
defined(PY_MAJOR_VERSION).
When the major or minor version changes, the VERSION variable in
configure.in must also be changed.
There is also (independent) API version information in modsupport.h.
*/
/* Values for PY_RELEASE_LEVEL */
#define PY_RELEASE_LEVEL_ALPHA 0xA
#define PY_RELEASE_LEVEL_BETA 0xB
#define PY_RELEASE_LEVEL_GAMMA 0xC /* For release candidates */
#define PY_RELEASE_LEVEL_FINAL 0xF /* Serial should be 0 here */
/* Higher for patch releases */
/* Version parsed out into numeric values */
#define PY_MAJOR_VERSION 3
#define PY_MINOR_VERSION 9
#define PY_MICRO_VERSION 18
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL
#define PY_RELEASE_SERIAL 0
/* Version as a string */
#define PY_VERSION "3.9.18"
/* PyPy version as a string: make sure to keep this in sync with:
* module/sys/version.py
* doc/conf.py
*/
#define PYPY_VERSION "7.3.13"
#define PYPY_VERSION_NUM 0x07030d00
/* Defined to mean a PyPy where cpyext holds more regular references
to PyObjects, e.g. staying alive as long as the internal PyPy object
stays alive. */
#define PYPY_CPYEXT_GC 1
#define PyPy_Borrow(a, b) ((void) 0)
/* Subversion Revision number of this file (not of the repository).
* Empty since Mercurial migration. */
#define PY_PATCHLEVEL_REVISION ""
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.
Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */
#define PY_VERSION_HEX ((PY_MAJOR_VERSION << 24) | \
(PY_MINOR_VERSION << 16) | \
(PY_MICRO_VERSION << 8) | \
(PY_RELEASE_LEVEL << 4) | \
(PY_RELEASE_SERIAL << 0))

View File

@ -0,0 +1,58 @@
/* Capsule objects let you wrap a C "void *" pointer in a Python
object. They're a way of passing data through the Python interpreter
without creating your own custom type.
Capsules are used for communication between extension modules.
They provide a way for an extension module to export a C interface
to other extension modules, so that extension modules can use the
Python import mechanism to link to one another.
For more information, please see "c-api/capsule.html" in the
documentation.
*/
#ifndef Py_CAPSULE_H
#define Py_CAPSULE_H
#ifdef __cplusplus
extern "C" {
#endif
PyAPI_DATA(PyTypeObject) PyCapsule_Type;
typedef void (*PyCapsule_Destructor)(PyObject *);
#define PyCapsule_CheckExact(op) (Py_TYPE(op) == &PyCapsule_Type)
PyAPI_FUNC(PyObject *) PyCapsule_New(
void *pointer,
const char *name,
PyCapsule_Destructor destructor);
PyAPI_FUNC(void *) PyCapsule_GetPointer(PyObject *capsule, const char *name);
PyAPI_FUNC(PyCapsule_Destructor) PyCapsule_GetDestructor(PyObject *capsule);
PyAPI_FUNC(const char *) PyCapsule_GetName(PyObject *capsule);
PyAPI_FUNC(void *) PyCapsule_GetContext(PyObject *capsule);
PyAPI_FUNC(int) PyCapsule_IsValid(PyObject *capsule, const char *name);
PyAPI_FUNC(int) PyCapsule_SetPointer(PyObject *capsule, void *pointer);
PyAPI_FUNC(int) PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor);
PyAPI_FUNC(int) PyCapsule_SetName(PyObject *capsule, const char *name);
PyAPI_FUNC(int) PyCapsule_SetContext(PyObject *capsule, void *context);
PyAPI_FUNC(void *) PyCapsule_Import(const char *name, int no_block);
PyAPI_FUNC(PyTypeObject *) _Py_get_capsule_type(void);
#ifdef __cplusplus
}
#endif
#endif /* !Py_CAPSULE_H */

View File

@ -0,0 +1,40 @@
#ifndef Py_PYCONFIG_H
#define Py_PYCONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
#define HAVE_PROTOTYPES 1
#define STDC_HEADERS 1
#define HAVE_LONG_LONG 1
#define HAVE_STDARG_PROTOTYPES 1
#define PY_FORMAT_LONG_LONG "ll"
#define PY_FORMAT_SIZE_T "z"
#define WITH_DOC_STRINGS
#define HAVE_UNICODE
#define WITHOUT_COMPLEX
#define HAVE_WCHAR_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
/* PyPy supposes Py_UNICODE == wchar_t */
#define HAVE_USABLE_WCHAR_T 1
#ifndef _WIN32
#define SIZEOF_WCHAR_T 4
#else
#define SIZEOF_WCHAR_T 2
#endif
#ifndef _WIN32
#define VA_LIST_IS_ARRAY
#ifndef __APPLE__
#define HAVE_CLOCK_GETTIME
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,55 @@
/* Exception interface */
#ifndef Py_PYERRORS_H
#define Py_PYERRORS_H
#ifdef __cplusplus
extern "C" {
#endif
#define PyExceptionClass_Check(x) \
((PyType_Check((x)) && \
PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS)))
#define PyExceptionInstance_Check(x) \
(PyObject_IsSubclass((PyObject *)Py_TYPE(x), PyExc_BaseException))
#define PyExc_EnvironmentError PyExc_OSError
#define PyExc_IOError PyExc_OSError
#ifdef MS_WINDOWS
#define PyExc_WindowsError PyExc_OSError
#endif
PyAPI_FUNC(PyObject *) PyErr_NewException(const char *name, PyObject *base, PyObject *dict);
PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc(const char *name, const char *doc, PyObject *base, PyObject *dict);
PyAPI_FUNC(PyObject *) PyErr_Format(PyObject *exception, const char *format, ...);
PyAPI_FUNC(PyObject *) _PyErr_FormatFromCause(PyObject *exception, const char *format, ...);
/* These APIs aren't really part of the error implementation, but
often needed to format error messages; the native C lib APIs are
not available on all platforms, which is why we provide emulations
for those platforms in Python/mysnprintf.c,
WARNING: The return value of snprintf varies across platforms; do
not rely on any particular behavior; eventually the C99 defn may
be reliable.
*/
#if defined(MS_WIN32) && !defined(HAVE_SNPRINTF)
# define HAVE_SNPRINTF
# define snprintf _snprintf
# define vsnprintf _vsnprintf
#endif
#include <stdarg.h>
PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...);
PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va);
typedef struct {
PyObject_HEAD /* xxx PyException_HEAD in CPython */
PyObject *value;
} PyStopIterationObject;
#ifdef __cplusplus
}
#endif
#endif /* !Py_PYERRORS_H */

View File

@ -0,0 +1,33 @@
#ifndef Py_HASH_H
#define Py_HASH_H
#ifdef __cplusplus
extern "C" {
#endif
/* Keep synced with rpython/rlib/objectmodel.py */
/* Prime multiplier used in string and various other hashes. */
#define _PyHASH_MULTIPLIER 1000003UL /* 0xf4243 */
/* Parameters used for the numeric hash implementation. See notes for
_Py_HashDouble in Python/pyhash.c. Numeric hashes are based on
reduction modulo the prime 2**_PyHASH_BITS - 1. */
#if SIZEOF_VOID_P >= 8
# define _PyHASH_BITS 61
#else
# define _PyHASH_BITS 31
#endif
#define _PyHASH_MODULUS (((size_t)1 << _PyHASH_BITS) - 1)
#define _PyHASH_INF 314159
#define _PyHASH_NAN 0
#define _PyHASH_IMAG _PyHASH_MULTIPLIER
#ifdef __cplusplus
}
#endif
#endif /* !Py_HASH_H */

View File

@ -0,0 +1,22 @@
#ifndef Py_PYLIFECYCLE_H
#define Py_PYLIFECYCLE_H
#ifdef __cplusplus
extern "C" {
#endif
/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
#ifndef Py_LIMITED_API
PyAPI_FUNC(void) _Py_RestoreSignals(void);
#endif
/* In Python <= 3.6 there is a variable _Py_Finalizing of type
'PyThreadState *'. Emulate it with a macro. */
#define _Py_Finalizing \
(_Py_IsFinalizing() ? _PyThreadState_UncheckedGet() : NULL)
#ifdef __cplusplus
}
#endif
#endif /* !Py_PYLIFECYCLE_H */

View File

@ -0,0 +1,98 @@
#ifndef Py_PYMACRO_H
#define Py_PYMACRO_H
/* Minimum value between x and y */
#define Py_MIN(x, y) (((x) > (y)) ? (y) : (x))
/* Maximum value between x and y */
#define Py_MAX(x, y) (((x) > (y)) ? (x) : (y))
/* Absolute value of the number x */
#define Py_ABS(x) ((x) < 0 ? -(x) : (x))
#define _Py_XSTRINGIFY(x) #x
/* Convert the argument to a string. For example, Py_STRINGIFY(123) is replaced
with "123" by the preprocessor. Defines are also replaced by their value.
For example Py_STRINGIFY(__LINE__) is replaced by the line number, not
by "__LINE__". */
#define Py_STRINGIFY(x) _Py_XSTRINGIFY(x)
/* Get the size of a structure member in bytes */
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
/* Argument must be a char or an int in [-128, 127] or [0, 255]. */
#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff))
/* Assert a build-time dependency, as an expression.
Your compile will fail if the condition isn't true, or can't be evaluated
by the compiler. This can be used in an expression: its value is 0.
Example:
#define foo_to_char(foo) \
((char *)(foo) \
+ Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) == 0))
Written by Rusty Russell, public domain, http://ccodearchive.net/ */
#define Py_BUILD_ASSERT_EXPR(cond) \
(sizeof(char [1 - 2*!(cond)]) - 1)
#define Py_BUILD_ASSERT(cond) do { \
(void)Py_BUILD_ASSERT_EXPR(cond); \
} while(0)
/* Get the number of elements in a visible array
This does not work on pointers, or arrays declared as [], or function
parameters. With correct compiler support, such usage will cause a build
error (see Py_BUILD_ASSERT_EXPR).
Written by Rusty Russell, public domain, http://ccodearchive.net/
Requires at GCC 3.1+ */
#if (defined(__GNUC__) && !defined(__STRICT_ANSI__) && \
(((__GNUC__ == 3) && (__GNU_MINOR__ >= 1)) || (__GNUC__ >= 4)))
/* Two gcc extensions.
&a[0] degrades to a pointer: a different type from an array */
#define Py_ARRAY_LENGTH(array) \
(sizeof(array) / sizeof((array)[0]) \
+ Py_BUILD_ASSERT_EXPR(!__builtin_types_compatible_p(typeof(array), \
typeof(&(array)[0]))))
#else
#define Py_ARRAY_LENGTH(array) \
(sizeof(array) / sizeof((array)[0]))
#endif
/* Define macros for inline documentation. */
#define PyDoc_VAR(name) static char name[]
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
#ifdef WITH_DOC_STRINGS
#define PyDoc_STR(str) str
#else
#define PyDoc_STR(str) ""
#endif
/* Below "a" is a power of 2. */
/* Round down size "n" to be a multiple of "a". */
#define _Py_SIZE_ROUND_DOWN(n, a) ((size_t)(n) & ~(size_t)((a) - 1))
/* Round up size "n" to be a multiple of "a". */
#define _Py_SIZE_ROUND_UP(n, a) (((size_t)(n) + \
(size_t)((a) - 1)) & ~(size_t)((a) - 1))
/* Round pointer "p" down to the closest "a"-aligned address <= "p". */
#define _Py_ALIGN_DOWN(p, a) ((void *)((uintptr_t)(p) & ~(uintptr_t)((a) - 1)))
/* Round pointer "p" up to the closest "a"-aligned address >= "p". */
#define _Py_ALIGN_UP(p, a) ((void *)(((uintptr_t)(p) + \
(uintptr_t)((a) - 1)) & ~(uintptr_t)((a) - 1)))
/* Check if pointer "p" is aligned to "a"-bytes boundary. */
#define _Py_IS_ALIGNED(p, a) (!((uintptr_t)(p) & (uintptr_t)((a) - 1)))
#ifdef __GNUC__
#define Py_UNUSED(name) _unused_ ## name __attribute__((unused))
#else
#define Py_UNUSED(name) _unused_ ## name
#endif
#endif /* Py_PYMACRO_H */

View File

@ -0,0 +1,106 @@
#ifndef Py_PYMATH_H
#define Py_PYMATH_H
/**************************************************************************
Symbols and macros to supply platform-independent interfaces to mathematical
functions and constants
**************************************************************************/
/* High precision definition of pi and e (Euler)
* The values are taken from libc6's math.h.
*/
#ifndef Py_MATH_PIl
#define Py_MATH_PIl 3.1415926535897932384626433832795029L
#endif
#ifndef Py_MATH_PI
#define Py_MATH_PI 3.14159265358979323846
#endif
#ifndef Py_MATH_El
#define Py_MATH_El 2.7182818284590452353602874713526625L
#endif
#ifndef Py_MATH_E
#define Py_MATH_E 2.7182818284590452354
#endif
/* Tau (2pi) to 40 digits, taken from tauday.com/tau-digits. */
#ifndef Py_MATH_TAU
#define Py_MATH_TAU 6.2831853071795864769252867665590057683943L
#endif
/* Py_IS_NAN(X)
* Return 1 if float or double arg is a NaN, else 0.
* Caution:
* X is evaluated more than once.
* This may not work on all platforms. Each platform has *some*
* way to spell this, though -- override in pyconfig.h if you have
* a platform where it doesn't work.
*/
#ifndef Py_IS_NAN
#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
#define Py_IS_NAN(X) isnan(X)
#else
#define Py_IS_NAN(X) ((X) != (X))
#endif
#endif
/* Py_IS_INFINITY(X)
* Return 1 if float or double arg is an infinity, else 0.
* Caution:
* X is evaluated more than once.
* This implementation may set the underflow flag if |X| is very small;
* it really can't be implemented correctly (& easily) before C99.
* Override in pyconfig.h if you have a better spelling on your platform.
*/
#ifndef Py_IS_INFINITY
# if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
# define Py_IS_INFINITY(X) isinf(X)
# else
# define Py_IS_INFINITY(X) ((X) && ((X)*0.5 == (X)))
# endif
#endif
/* Py_IS_FINITE(X)
* Return 1 if float or double arg is neither infinite nor NAN, else 0.
* Some compilers (e.g. VisualStudio) have intrinsics for this, so a special
* macro for this particular test is useful
*/
#ifndef Py_IS_FINITE
#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
#define Py_IS_FINITE(X) isfinite(X)
#else
#define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X))
#endif
#endif
/* HUGE_VAL is supposed to expand to a positive double infinity. Python
* uses Py_HUGE_VAL instead because some platforms are broken in this
* respect. We used to embed code in pyport.h to try to worm around that,
* but different platforms are broken in conflicting ways. If you're on
* a platform where HUGE_VAL is defined incorrectly, fiddle your Python
* config to #define Py_HUGE_VAL to something that works on your platform.
*/
#ifndef Py_HUGE_VAL
#define Py_HUGE_VAL HUGE_VAL
#endif
/* Py_NAN: Value that evaluates to a quiet Not-a-Number (NaN). The sign is
* undefined and normally not relevant, but e.g. fixed for float("nan").
*/
#if !defined(Py_NAN)
# define Py_NAN ((double)NAN)
#endif
/* Return whether integral type *type* is signed or not. */
#define _Py_IntegralTypeSigned(type) ((type)(-1) < 0)
/* Return the maximum value of integral type *type*. */
#define _Py_IntegralTypeMax(type) ((_Py_IntegralTypeSigned(type)) ? (((((type)1 << (sizeof(type)*CHAR_BIT - 2)) - 1) << 1) + 1) : ~(type)0)
/* Return the minimum value of integral type *type*. */
#define _Py_IntegralTypeMin(type) ((_Py_IntegralTypeSigned(type)) ? -_Py_IntegralTypeMax(type) - 1 : 0)
/* Check whether *v* is in the range of integral type *type*. This is most
* useful if *v* is floating-point, since demoting a floating-point *v* to an
* integral type that cannot represent *v*'s integral part is undefined
* behavior. */
#define _Py_InIntegralTypeRange(type, v) (_Py_IntegralTypeMin(type) <= v && v <= _Py_IntegralTypeMax(type))
#endif /* Py_PYMATH_H */

View File

@ -0,0 +1,88 @@
#include <stdlib.h>
#ifndef Py_PYMEM_H
#define Py_PYMEM_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef Py_LIMITED_API
PyAPI_FUNC(void *) PyMem_RawMalloc(size_t size);
PyAPI_FUNC(void *) PyMem_RawCalloc(size_t nelem, size_t elsize);
PyAPI_FUNC(void *) PyMem_RawRealloc(void *ptr, size_t new_size);
PyAPI_FUNC(void) PyMem_RawFree(void *ptr);
#endif
PyAPI_FUNC(void *) PyMem_Malloc(size_t size);
PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize);
PyAPI_FUNC(void *) PyMem_Realloc(void *ptr, size_t new_size);
PyAPI_FUNC(void) PyMem_Free(void *ptr);
#define PyMem_MALLOC(n) PyMem_Malloc(n)
#define PyMem_REALLOC(p, n) PyMem_Realloc(p, n)
#define PyMem_FREE(p) PyMem_Free(p)
/*
* Type-oriented memory interface
* ==============================
*
* Allocate memory for n objects of the given type. Returns a new pointer
* or NULL if the request was too large or memory allocation failed. Use
* these macros rather than doing the multiplication yourself so that proper
* overflow checking is always done.
*/
#define PyMem_New(type, n) \
( ((n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
( (type *) PyMem_Malloc((n) * sizeof(type)) ) )
#define PyMem_NEW(type, n) \
( ((n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
( (type *) PyMem_MALLOC((n) * sizeof(type)) ) )
/*
* The value of (p) is always clobbered by this macro regardless of success.
* The caller MUST check if (p) is NULL afterwards and deal with the memory
* error if so. This means the original value of (p) MUST be saved for the
* caller's memory error handler to not lose track of it.
*/
#define PyMem_Resize(p, type, n) \
( (p) = ((n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
(type *) PyMem_Realloc((p), (n) * sizeof(type)) )
#define PyMem_RESIZE(p, type, n) \
( (p) = ((n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
(type *) PyMem_REALLOC((p), (n) * sizeof(type)) )
/* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used
* anymore. They're just confusing aliases for PyMem_{Free,FREE} now.
*/
#define PyMem_Del PyMem_Free
#define PyMem_DEL PyMem_FREE
/* From CPython 3.6, with a different goal. PyTraceMalloc_Track()
* is equivalent to __pypy__.add_memory_pressure(size); it works with
* or without the GIL. PyTraceMalloc_Untrack() is an empty stub.
* From CPython 3.7 these are public API functions
*
* #if defined(PYPY_TRACEMALLOC) || \
* (PY_VERSION_HEX >= 0x03060000 && !defined(Py_LIMITED_API))
*/
#define PYPY_TRACEMALLOC 1
PyAPI_FUNC(int) PyTraceMalloc_Track(
unsigned int domain,
uintptr_t ptr,
size_t size);
PyAPI_FUNC(int) PyTraceMalloc_Untrack(
unsigned int domain,
uintptr_t ptr);
#ifdef __cplusplus
}
#endif
#endif /* !Py_PYMEM_H */

View File

@ -0,0 +1,330 @@
#ifndef Py_PYPORT_H
#define Py_PYPORT_H
#include <pyconfig.h> /* include for defines */
#include <inttypes.h>
/**************************************************************************
Symbols and macros to supply platform-independent interfaces to basic
C language & library operations whose spellings vary across platforms.
Please try to make documentation here as clear as possible: by definition,
the stuff here is trying to illuminate C's darkest corners.
Config #defines referenced here:
SIGNED_RIGHT_SHIFT_ZERO_FILLS
Meaning: To be defined iff i>>j does not extend the sign bit when i is a
signed integral type and i < 0.
Used in: Py_ARITHMETIC_RIGHT_SHIFT
Py_DEBUG
Meaning: Extra checks compiled in for debug mode.
Used in: Py_SAFE_DOWNCAST
**************************************************************************/
/* typedefs for some C9X-defined synonyms for integral types.
*
* The names in Python are exactly the same as the C9X names, except with a
* Py_ prefix. Until C9X is universally implemented, this is the only way
* to ensure that Python gets reliable names that don't conflict with names
* in non-Python code that are playing their own tricks to define the C9X
* names.
*
* NOTE: don't go nuts here! Python has no use for *most* of the C9X
* integral synonyms. Only define the ones we actually need.
*/
/* typedefs for some C9X-defined synonyms for integral types. */
#ifndef PY_LONG_LONG
#define PY_LONG_LONG long long
/* If LLONG_MAX is defined in limits.h, use that. */
#define PY_LLONG_MIN LLONG_MIN
#define PY_LLONG_MAX LLONG_MAX
#define PY_ULLONG_MAX ULLONG_MAX
#endif
#define PY_UINT32_T uint32_t
#define PY_UINT64_T uint64_t
/* Signed variants of the above */
#define PY_INT32_T int32_t
#define PY_INT64_T int64_t
/* uintptr_t is the C9X name for an unsigned integral type such that a
* legitimate void* can be cast to uintptr_t and then back to void* again
* without loss of information. Similarly for intptr_t, wrt a signed
* integral type.
*/
typedef uintptr_t Py_uintptr_t;
typedef intptr_t Py_intptr_t;
/* CPython does this differently */
#ifdef _WIN64
typedef long long Py_ssize_t;
typedef long long Py_hash_t;
typedef unsigned long long Py_uhash_t;
#else
typedef long Py_ssize_t;
typedef long Py_hash_t;
typedef unsigned long Py_uhash_t;
#endif
/* Py_hash_t is the same size as a pointer. */
#define SIZEOF_PY_HASH_T SIZEOF_SIZE_T
/* Py_uhash_t is the unsigned equivalent needed to calculate numeric hash. */
#define SIZEOF_PY_UHASH_T SIZEOF_SIZE_T
/* Largest possible value of size_t. */
#define PY_SIZE_MAX SIZE_MAX
/* Largest positive value of type Py_ssize_t. */
#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
/* Smallest negative value of type Py_ssize_t. */
#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
#include <stdarg.h>
/* Py_LOCAL can be used instead of static to get the fastest possible calling
* convention for functions that are local to a given module.
*
* Py_LOCAL_INLINE does the same thing, and also explicitly requests inlining,
* for platforms that support that.
*
* If PY_LOCAL_AGGRESSIVE is defined before python.h is included, more
* "aggressive" inlining/optimization is enabled for the entire module. This
* may lead to code bloat, and may slow things down for those reasons. It may
* also lead to errors, if the code relies on pointer aliasing. Use with
* care.
*
* NOTE: You can only use this for functions that are entirely local to a
* module; functions that are exported via method tables, callbacks, etc,
* should keep using static.
*/
#if defined(_MSC_VER)
# if defined(PY_LOCAL_AGGRESSIVE)
/* enable more aggressive optimization for MSVC */
/* active in both release and debug builds - see bpo-43271 */
# pragma optimize("gt", on)
#endif
/* ignore warnings if the compiler decides not to inline a function */
# pragma warning(disable: 4710)
/* fastest possible local call under MSVC */
# define Py_LOCAL(type) static type __fastcall
# define Py_LOCAL_INLINE(type) static __inline type __fastcall
#else
# define Py_LOCAL(type) static type
# define Py_LOCAL_INLINE(type) static inline type
#endif
/* CPython needs this for the c-extension datetime, which is pure python on PyPy
downstream packages assume it is here (Pandas for instance) */
#include <time.h>
#ifndef _MSC_VER
#include <sys/time.h>
#endif
/*******************************
* stat() and fstat() fiddling *
*******************************/
/* We expect that stat and fstat exist on most systems.
* It's confirmed on Unix, Mac and Windows.
* If you don't have them, add
* #define DONT_HAVE_STAT
* and/or
* #define DONT_HAVE_FSTAT
* to your pyconfig.h. Python code beyond this should check HAVE_STAT and
* HAVE_FSTAT instead.
* Also
* #define HAVE_SYS_STAT_H
* if <sys/stat.h> exists on your platform, and
* #define HAVE_STAT_H
* if <stat.h> does.
*/
#ifndef DONT_HAVE_STAT
#define HAVE_STAT
#endif
#ifndef DONT_HAVE_FSTAT
#define HAVE_FSTAT
#endif
#ifdef RISCOS
#include <sys/types.h>
#include "unixstuff.h"
#endif
#ifdef HAVE_SYS_STAT_H
#if defined(PYOS_OS2) && defined(PYCC_GCC)
#include <sys/types.h>
#endif
#include <sys/stat.h>
#elif defined(HAVE_STAT_H)
#include <stat.h>
#else
#endif
/* Py_DEPRECATED(version)
* Declare a variable, type, or function deprecated.
* The macro must be placed before the declaration.
* Usage:
* Py_DEPRECATED(3.3) extern int old_var;
* Py_DEPRECATED(3.4) typedef int T1;
* Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void);
*/
#if defined(__GNUC__) \
&& ((__GNUC__ >= 4) || (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
#elif defined(_MSC_VER)
#define Py_DEPRECATED(VERSION) __declspec(deprecated( \
"deprecated in " #VERSION))
#else
#define Py_DEPRECATED(VERSION_UNUSED)
#endif
/* Declarations for symbol visibility.
PyAPI_FUNC(type): Declares a public Python API function and return type
PyAPI_DATA(type): Declares public Python data and its type
PyMODINIT_FUNC: A Python module init function. If these functions are
inside the Python core, they are private to the core.
If in an extension module, it may be declared with
external linkage depending on the platform.
As a number of platforms support/require "__declspec(dllimport/dllexport)",
we support a HAVE_DECLSPEC_DLL macro to save duplication.
*/
/*
All windows ports, except cygwin, are handled in PC/pyconfig.h.
Cygwin is the only other autoconf platform requiring special
linkage handling and it uses __declspec().
*/
#if defined(__CYGWIN__)
# define HAVE_DECLSPEC_DLL
#endif
#include "exports.h"
/* only get special linkage if built as shared or platform is Cygwin */
#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__)
# if defined(HAVE_DECLSPEC_DLL)
# if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# define PyAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE
# define PyAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE
/* module init functions inside the core need no external linkage */
/* except for Cygwin to handle embedding */
# if defined(__CYGWIN__)
# define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject*
# else /* __CYGWIN__ */
# define PyMODINIT_FUNC PyObject*
# endif /* __CYGWIN__ */
# else /* Py_BUILD_CORE */
/* Building an extension module, or an embedded situation */
/* public Python functions and data are imported */
/* Under Cygwin, auto-import functions to prevent compilation */
/* failures similar to those described at the bottom of 4.1: */
/* http://docs.python.org/extending/windows.html#a-cookbook-approach */
# if !defined(__CYGWIN__)
# define PyAPI_FUNC(RTYPE) Py_IMPORTED_SYMBOL RTYPE
# endif /* !__CYGWIN__ */
# define PyAPI_DATA(RTYPE) extern Py_IMPORTED_SYMBOL RTYPE
/* module init functions outside the core must be exported */
# if defined(__cplusplus)
# define PyMODINIT_FUNC extern "C" Py_EXPORTED_SYMBOL PyObject*
# else /* __cplusplus */
# define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject*
# endif /* __cplusplus */
# endif /* Py_BUILD_CORE */
# endif /* HAVE_DECLSPEC_DLL */
#endif /* Py_ENABLE_SHARED */
/* If no external linkage macros defined by now, create defaults */
#ifndef PyAPI_FUNC
# define PyAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE
#endif
#ifndef PyAPI_DATA
# define PyAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE
#endif
#ifndef PyMODINIT_FUNC
# if defined(__cplusplus)
# define PyMODINIT_FUNC extern "C" Py_EXPORTED_SYMBOL PyObject*
# else /* __cplusplus */
# define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject*
# endif /* __cplusplus */
#endif
/*
* Hide GCC attributes from compilers that don't support them.
*/
#if (!defined(__GNUC__) || __GNUC__ < 2 || \
(__GNUC__ == 2 && __GNUC_MINOR__ < 7) )
#define Py_GCC_ATTRIBUTE(x)
#else
#define Py_GCC_ATTRIBUTE(x) __attribute__(x)
#endif
/*
* Specify alignment on compilers that support it.
*/
#if defined(__GNUC__) && __GNUC__ >= 3
#define Py_ALIGNED(x) __attribute__((aligned(x)))
#else
#define Py_ALIGNED(x)
#endif
/* Eliminate end-of-loop code not reached warnings from SunPro C
* when using do{...}while(0) macros
*/
#ifdef __SUNPRO_C
#pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED)
#endif
#ifndef Py_LL
#define Py_LL(x) x##LL
#endif
#ifndef Py_ULL
#define Py_ULL(x) Py_LL(x##U)
#endif
#define Py_VA_COPY va_copy
/* Mark a function which cannot return. Example:
PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void);
XLC support is intentionally omitted due to bpo-40244 */
#if defined(__clang__) || \
(defined(__GNUC__) && \
((__GNUC__ >= 3) || \
(__GNUC__ == 2) && (__GNUC_MINOR__ >= 5)))
# define _Py_NO_RETURN __attribute__((__noreturn__))
#elif defined(_MSC_VER)
# define _Py_NO_RETURN __declspec(noreturn)
#else
# define _Py_NO_RETURN
#endif
// Preprocessor check for a builtin preprocessor function. Always return 0
// if __has_builtin() macro is not defined.
//
// __has_builtin() is available on clang and GCC 10.
#ifdef __has_builtin
# define _Py__has_builtin(x) __has_builtin(x)
#else
# define _Py__has_builtin(x) 0
#endif
#endif /* Py_PYPORT_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,160 @@
#define Py_FatalError PyPy_FatalError
#define PyOS_snprintf PyPyOS_snprintf
#define PyOS_vsnprintf PyPyOS_vsnprintf
#define PyArg_Parse PyPyArg_Parse
#define PyArg_ParseTuple PyPyArg_ParseTuple
#define PyArg_UnpackTuple PyPyArg_UnpackTuple
#define PyArg_ParseTupleAndKeywords PyPyArg_ParseTupleAndKeywords
#define PyArg_VaParse PyPyArg_VaParse
#define PyArg_VaParseTupleAndKeywords PyPyArg_VaParseTupleAndKeywords
#define _PyArg_NoKeywords _PyPyArg_NoKeywords
#define PyUnicode_FromFormat PyPyUnicode_FromFormat
#define PyUnicode_FromFormatV PyPyUnicode_FromFormatV
#define PyUnicode_AsWideCharString PyPyUnicode_AsWideCharString
#define PyUnicode_GetSize PyPyUnicode_GetSize
#define PyUnicode_GetLength PyPyUnicode_GetLength
#define PyUnicode_FromWideChar PyPyUnicode_FromWideChar
#define PyModule_AddObject PyPyModule_AddObject
#define PyModule_AddIntConstant PyPyModule_AddIntConstant
#define PyModule_AddStringConstant PyPyModule_AddStringConstant
#define PyModule_GetDef PyPyModule_GetDef
#define PyModuleDef_Init PyPyModuleDef_Init
#define PyModule_GetState PyPyModule_GetState
#define Py_BuildValue PyPy_BuildValue
#define Py_VaBuildValue PyPy_VaBuildValue
#define PyTuple_Pack PyPyTuple_Pack
#define _PyArg_Parse_SizeT _PyPyArg_Parse_SizeT
#define _PyArg_ParseTuple_SizeT _PyPyArg_ParseTuple_SizeT
#define _PyArg_ParseTupleAndKeywords_SizeT _PyPyArg_ParseTupleAndKeywords_SizeT
#define _PyArg_VaParse_SizeT _PyPyArg_VaParse_SizeT
#define _PyArg_VaParseTupleAndKeywords_SizeT _PyPyArg_VaParseTupleAndKeywords_SizeT
#define _Py_BuildValue_SizeT _PyPy_BuildValue_SizeT
#define _Py_VaBuildValue_SizeT _PyPy_VaBuildValue_SizeT
#define PyUnicode_AppendAndDel PyPyUnicode_AppendAndDel
#define PyErr_Format PyPyErr_Format
#define PyErr_NewException PyPyErr_NewException
#define PyErr_NewExceptionWithDoc PyPyErr_NewExceptionWithDoc
#define PyErr_WarnFormat PyPyErr_WarnFormat
#define _PyErr_FormatFromCause _PyPyErr_FormatFromCause
#define PySys_WriteStdout PyPySys_WriteStdout
#define PySys_WriteStderr PyPySys_WriteStderr
#define PyEval_CallFunction PyPyEval_CallFunction
#define PyEval_CallMethod PyPyEval_CallMethod
#define PyObject_CallFunction PyPyObject_CallFunction
#define PyObject_CallMethod PyPyObject_CallMethod
#define PyObject_CallFunctionObjArgs PyPyObject_CallFunctionObjArgs
#define PyObject_CallMethodObjArgs PyPyObject_CallMethodObjArgs
#define _PyObject_CallFunction_SizeT _PyPyObject_CallFunction_SizeT
#define _PyObject_CallMethod_SizeT _PyPyObject_CallMethod_SizeT
#define PyObject_DelItemString PyPyObject_DelItemString
#define PyObject_GetBuffer PyPyObject_GetBuffer
#define PyBuffer_Release PyPyBuffer_Release
#define _Py_setfilesystemdefaultencoding _PyPy_setfilesystemdefaultencoding
#define PyCapsule_New PyPyCapsule_New
#define PyCapsule_IsValid PyPyCapsule_IsValid
#define PyCapsule_GetPointer PyPyCapsule_GetPointer
#define PyCapsule_GetName PyPyCapsule_GetName
#define PyCapsule_GetDestructor PyPyCapsule_GetDestructor
#define PyCapsule_GetContext PyPyCapsule_GetContext
#define PyCapsule_SetPointer PyPyCapsule_SetPointer
#define PyCapsule_SetName PyPyCapsule_SetName
#define PyCapsule_SetDestructor PyPyCapsule_SetDestructor
#define PyCapsule_SetContext PyPyCapsule_SetContext
#define PyCapsule_Import PyPyCapsule_Import
#define PyCapsule_Type PyPyCapsule_Type
#define _Py_get_capsule_type _PyPy_get_capsule_type
#define PyComplex_AsCComplex PyPyComplex_AsCComplex
#define PyComplex_FromCComplex PyPyComplex_FromCComplex
#define PyObject_AsReadBuffer PyPyObject_AsReadBuffer
#define PyObject_AsWriteBuffer PyPyObject_AsWriteBuffer
#define PyObject_CheckReadBuffer PyPyObject_CheckReadBuffer
#define PyBuffer_GetPointer PyPyBuffer_GetPointer
#define PyBuffer_ToContiguous PyPyBuffer_ToContiguous
#define PyBuffer_FromContiguous PyPyBuffer_FromContiguous
#define PyImport_ImportModuleLevel PyPyImport_ImportModuleLevel
#define PyOS_getsig PyPyOS_getsig
#define PyOS_setsig PyPyOS_setsig
#define _Py_RestoreSignals _PyPy_RestoreSignals
#define PyThread_get_thread_ident PyPyThread_get_thread_ident
#define PyThread_allocate_lock PyPyThread_allocate_lock
#define PyThread_free_lock PyPyThread_free_lock
#define PyThread_acquire_lock PyPyThread_acquire_lock
#define PyThread_release_lock PyPyThread_release_lock
#define PyThread_create_key PyPyThread_create_key
#define PyThread_delete_key PyPyThread_delete_key
#define PyThread_set_key_value PyPyThread_set_key_value
#define PyThread_get_key_value PyPyThread_get_key_value
#define PyThread_delete_key_value PyPyThread_delete_key_value
#define PyThread_ReInitTLS PyPyThread_ReInitTLS
#define PyThread_init_thread PyPyThread_init_thread
#define PyThread_start_new_thread PyPyThread_start_new_thread
#define PyStructSequence_InitType PyPyStructSequence_InitType
#define PyStructSequence_InitType2 PyPyStructSequence_InitType2
#define PyStructSequence_New PyPyStructSequence_New
#define PyStructSequence_UnnamedField PyPyStructSequence_UnnamedField
#define PyStructSequence_NewType PyPyStructSequence_NewType
#define PyStructSequence_GetItem PyPyStructSequence_GetItem
#define PyStructSequence_SetItem PyPyStructSequence_SetItem
#define PyFunction_Type PyPyFunction_Type
#define PyMethod_Type PyPyMethod_Type
#define PyRange_Type PyPyRange_Type
#define PyTraceBack_Type PyPyTraceBack_Type
#define Py_FrozenFlag PyPy_FrozenFlag
#define Py_UnbufferedStdioFlag PyPy_UnbufferedStdioFlag
#define _Py_PackageContext _PyPy_PackageContext
#define PyOS_InputHook PyPyOS_InputHook
#define _Py_PackageContext _PyPy_PackageContext
#define PyMem_RawMalloc PyPyMem_RawMalloc
#define PyMem_RawCalloc PyPyMem_RawCalloc
#define PyMem_RawRealloc PyPyMem_RawRealloc
#define PyMem_RawFree PyPyMem_RawFree
#define PyMem_Malloc PyPyMem_Malloc
#define PyMem_Calloc PyPyMem_Calloc
#define PyMem_Realloc PyPyMem_Realloc
#define PyMem_Free PyPyMem_Free
#define PyObject_CallFinalizerFromDealloc PyPyObject_CallFinalizerFromDealloc
#define PyTraceMalloc_Track PyPyTraceMalloc_Track
#define PyTraceMalloc_Untrack PyPyTraceMalloc_Untrack
#define PyBytes_FromFormat PyPyBytes_FromFormat
#define PyBytes_FromFormatV PyPyBytes_FromFormatV
#define PyType_FromSpec PyPyType_FromSpec
#define PyType_GetModule PyPyType_GetModule
#define PyType_GetModuleState PyPyType_GetModuleState
#define Py_IncRef PyPy_IncRef
#define Py_DecRef PyPy_DecRef
#define PyObject_Free PyPyObject_Free
#define PyObject_GC_Del PyPyObject_GC_Del
#define PyType_GenericAlloc PyPyType_GenericAlloc
#define _PyObject_New _PyPyObject_New
#define _PyObject_NewVar _PyPyObject_NewVar
#define _PyObject_GC_Malloc _PyPyObject_GC_Malloc
#define _PyObject_GC_New _PyPyObject_GC_New
#define _PyObject_GC_NewVar _PyPyObject_GC_NewVar
#define PyObject_Init PyPyObject_Init
#define PyObject_InitVar PyPyObject_InitVar
#define PyTuple_New PyPyTuple_New
#define _Py_Dealloc _PyPy_Dealloc
#define _Py_object_dealloc _PyPy_object_dealloc
#define PyVectorcall_Call PyPyVectorcall_Call
#define Py_DebugFlag PyPy_DebugFlag
#define Py_InspectFlag PyPy_InspectFlag
#define Py_InteractiveFlag PyPy_InteractiveFlag
#define Py_OptimizeFlag PyPy_OptimizeFlag
#define Py_DontWriteBytecodeFlag PyPy_DontWriteBytecodeFlag
#define Py_NoUserSiteDirectory PyPy_NoUserSiteDirectory
#define Py_NoSiteFlag PyPy_NoSiteFlag
#define Py_IgnoreEnvironmentFlag PyPy_IgnoreEnvironmentFlag
#define Py_VerboseFlag PyPy_VerboseFlag
#define Py_BytesWarningFlag PyPy_BytesWarningFlag
#define Py_QuietFlag PyPy_QuietFlag
#define Py_HashRandomizationFlag PyPy_HashRandomizationFlag
#define Py_IsolatedFlag PyPy_IsolatedFlag
#define SIZEOF_LONG_LONG 8
#define SIZEOF_VOID_P 8
#define SIZEOF_SIZE_T 8
#define SIZEOF_TIME_T 8
#define SIZEOF_LONG 8
#define SIZEOF_SHORT 2
#define SIZEOF_INT 4
#define SIZEOF_FLOAT 4
#define SIZEOF_DOUBLE 8

View File

@ -0,0 +1,17 @@
#include "cpyext_object.h"
#ifdef _WIN64
#define Signed Py_ssize_t /* xxx temporary fix */
#define Unsigned unsigned long long /* xxx temporary fix */
#else
#define Signed Py_ssize_t /* xxx temporary fix */
#define Unsigned unsigned long /* xxx temporary fix */
#endif
#define PyMarshal_ReadObjectFromString PyPyMarshal_ReadObjectFromString
PyAPI_FUNC(struct _object *) PyMarshal_ReadObjectFromString(char *arg0, Signed arg1);
#define PyMarshal_WriteObjectToString PyPyMarshal_WriteObjectToString
PyAPI_FUNC(struct _object *) PyMarshal_WriteObjectToString(struct _object *arg0, int arg1);
#undef Signed /* xxx temporary fix */
#undef Unsigned /* xxx temporary fix */

View File

@ -0,0 +1,17 @@
#include "cpyext_object.h"
#ifdef _WIN64
#define Signed Py_ssize_t /* xxx temporary fix */
#define Unsigned unsigned long long /* xxx temporary fix */
#else
#define Signed Py_ssize_t /* xxx temporary fix */
#define Unsigned unsigned long /* xxx temporary fix */
#endif
#define PyMember_GetOne PyPyMember_GetOne
PyAPI_FUNC(struct _object *) PyMember_GetOne(const char *arg0, struct PyMemberDef *arg1);
#define PyMember_SetOne PyPyMember_SetOne
PyAPI_FUNC(int) PyMember_SetOne(char *arg0, struct PyMemberDef *arg1, struct _object *arg2);
#undef Signed /* xxx temporary fix */
#undef Unsigned /* xxx temporary fix */

View File

@ -0,0 +1,19 @@
/* signal interface */
#ifndef Py_PYSIGNALS_H
#define Py_PYSIGNALS_H
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*PyOS_sighandler_t)(int);
PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int sig, PyOS_sighandler_t handler);
PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int sig);
#ifdef __cplusplus
}
#endif
#endif /* !Py_PYSIGNALS_H */

View File

@ -0,0 +1,46 @@
/* Thread and interpreter state structures and their interfaces */
#ifndef Py_PYSTATE_H
#define Py_PYSTATE_H
#ifdef __cplusplus
extern "C" {
#endif
/* This limitation is for performance and simplicity. If needed it can be
removed (with effort). */
#define MAX_CO_EXTRA_USERS 255
/* Forward declarations for PyFrameObject, PyThreadState
and PyInterpreterState */
struct _ts;
struct _is;
typedef struct _is {
struct _is *next;
PyObject * modules_by_index;
} PyInterpreterState;
typedef struct _ts {
PyInterpreterState *interp;
PyObject *dict; /* Stores per-thread state */
} PyThreadState;
#define Py_BEGIN_ALLOW_THREADS { \
PyThreadState *_save; \
_save = PyEval_SaveThread();
#define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
}
enum {PyGILState_LOCKED, PyGILState_UNLOCKED};
typedef int PyGILState_STATE;
#define PyThreadState_GET() PyThreadState_Get()
PyAPI_FUNC(PyObject*) PyState_FindModule(struct PyModuleDef*);
#ifdef __cplusplus
}
#endif
#endif /* !Py_PYSTATE_H */

View File

@ -0,0 +1 @@
/* empty */

View File

@ -0,0 +1,23 @@
#ifndef Py_STRTOD_H
#define Py_STRTOD_H
#ifdef __cplusplus
extern "C" {
#endif
/* PyOS_double_to_string's "flags" parameter can be set to 0 or more of: */
#define Py_DTSF_SIGN 0x01 /* always add the sign */
#define Py_DTSF_ADD_DOT_0 0x02 /* if the result is an integer add ".0" */
#define Py_DTSF_ALT 0x04 /* "alternate" formatting. it's format_code
specific */
/* PyOS_double_to_string's "type", if non-NULL, will be set to one of: */
#define Py_DTST_FINITE 0
#define Py_DTST_INFINITE 1
#define Py_DTST_NAN 2
#ifdef __cplusplus
}
#endif
#endif /* !Py_STRTOD_H */

View File

@ -0,0 +1,62 @@
/* Interfaces to parse and execute pieces of python code */
#ifndef Py_PYTHONRUN_H
#define Py_PYTHONRUN_H
#ifdef __cplusplus
extern "C" {
#endif
PyAPI_FUNC(void) Py_FatalError(const char *msg);
/* taken from Python-3.2.3/Include/pydebug.h */
/* Note: they are always 0 for now, expect Py_DebugFlag which is always 1 */
PyAPI_DATA(int) Py_DebugFlag;
PyAPI_DATA(int) Py_VerboseFlag;
PyAPI_DATA(int) Py_QuietFlag;
PyAPI_DATA(int) Py_InteractiveFlag;
PyAPI_DATA(int) Py_InspectFlag;
PyAPI_DATA(int) Py_OptimizeFlag;
PyAPI_DATA(int) Py_NoSiteFlag;
PyAPI_DATA(int) Py_BytesWarningFlag;
PyAPI_DATA(int) Py_FrozenFlag; /* set when the python is "frozen" */
PyAPI_DATA(int) Py_IgnoreEnvironmentFlag;
PyAPI_DATA(int) Py_DontWriteBytecodeFlag;
PyAPI_DATA(int) Py_NoUserSiteDirectory;
PyAPI_DATA(int) Py_UnbufferedStdioFlag;
PyAPI_DATA(int) Py_HashRandomizationFlag;
PyAPI_DATA(int) Py_IsolatedFlag;
#ifdef _WIN32
PyAPI_DATA(int) Py_LegacyWindowsStdioFlag;
#endif
#define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s))
typedef struct {
int cf_flags; /* bitmask of CO_xxx flags relevant to future */
int cf_feature_version; /* minor Python version (PyCF_ONLY_AST) */
} PyCompilerFlags;
#define _PyCompilerFlags_INIT \
(PyCompilerFlags){.cf_flags = 0, .cf_feature_version = PY_MINOR_VERSION}
#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \
CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \
CO_FUTURE_UNICODE_LITERALS)
#define PyCF_MASK_OBSOLETE (CO_NESTED)
#define PyCF_SOURCE_IS_UTF8 0x0100
#define PyCF_DONT_IMPLY_DEDENT 0x0200
#define PyCF_ONLY_AST 0x0400
#define Py_CompileString(str, filename, start) Py_CompileStringFlags(str, filename, start, NULL)
/* Stuff with no proper home (yet) */
PyAPI_DATA(int) (*PyOS_InputHook)(void);
typedef int (*_pypy_pyos_inputhook)(void);
PyAPI_FUNC(_pypy_pyos_inputhook) _PyPy_get_PyOS_InputHook(void);
#ifdef __cplusplus
}
#endif
#endif /* !Py_PYTHONRUN_H */

View File

@ -0,0 +1,84 @@
#ifndef Py_PYTHREAD_H
#define Py_PYTHREAD_H
#define WITH_THREAD
typedef void *PyThread_type_lock;
#ifdef __cplusplus
extern "C" {
#endif
PyAPI_FUNC(long) PyThread_get_thread_ident(void);
PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void);
PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock);
PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int);
#define WAIT_LOCK 1
#define NOWAIT_LOCK 0
PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock);
PyAPI_FUNC(void) PyThread_init_thread(void);
PyAPI_FUNC(long) PyThread_start_new_thread(void (*func)(void *), void *arg);
/* Thread Local Storage (TLS) API */
PyAPI_FUNC(int) PyThread_create_key(void);
PyAPI_FUNC(void) PyThread_delete_key(int);
PyAPI_FUNC(int) PyThread_set_key_value(int, void *);
PyAPI_FUNC(void *) PyThread_get_key_value(int);
PyAPI_FUNC(void) PyThread_delete_key_value(int key);
/* Cleanup after a fork */
PyAPI_FUNC(void) PyThread_ReInitTLS(void);
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000
/* New in 3.7 */
/* Thread Specific Storage (TSS) API */
typedef struct _Py_tss_t Py_tss_t; /* opaque */
#ifndef Py_LIMITED_API
#if defined(_POSIX_THREADS)
/* Darwin needs pthread.h to know type name the pthread_key_t. */
# include <pthread.h>
# define NATIVE_TSS_KEY_T pthread_key_t
#elif defined(_WIN32)
/* In Windows, native TSS key type is DWORD,
but hardcode the unsigned long to avoid errors for include directive.
*/
# define NATIVE_TSS_KEY_T unsigned long
#else
# error "Require native threads. See https://bugs.python.org/issue31370"
#endif
/* When Py_LIMITED_API is not defined, the type layout of Py_tss_t is
exposed to allow static allocation in the API clients. Even in this case,
you must handle TSS keys through API functions due to compatibility.
*/
struct _Py_tss_t {
int _is_initialized;
NATIVE_TSS_KEY_T _key;
};
#undef NATIVE_TSS_KEY_T
/* When static allocation, you must initialize with Py_tss_NEEDS_INIT. */
#define Py_tss_NEEDS_INIT {0}
#endif /* !Py_LIMITED_API */
PyAPI_FUNC(Py_tss_t *) PyThread_tss_alloc(void);
PyAPI_FUNC(void) PyThread_tss_free(Py_tss_t *key);
/* The parameter key must not be NULL. */
PyAPI_FUNC(int) PyThread_tss_is_created(Py_tss_t *key);
PyAPI_FUNC(int) PyThread_tss_create(Py_tss_t *key);
PyAPI_FUNC(void) PyThread_tss_delete(Py_tss_t *key);
PyAPI_FUNC(int) PyThread_tss_set(Py_tss_t *key, void *value);
PyAPI_FUNC(void *) PyThread_tss_get(Py_tss_t *key);
#endif /* New in 3.7 */
#ifdef __cplusplus
}
#endif
#endif

Some files were not shown because too many files have changed in this diff Show More