forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 2
Adding Deep Immutability to 3.12 #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
matajoh
wants to merge
40
commits into
mjp41:v3.12.0
Choose a base branch
from
matajoh:immutable-pep
base: v3.12.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
7ad9131
Proposed code changes for [PEP XXX](link).
matajoh 3b832e6
Addressing PR comments
matajoh d52b222
Cleaning up the immutability code
matajoh 80b648c
deque working
matajoh 697d3b1
Adding write barriers for array
matajoh 4024677
Cleaning up function freezing + more tests
matajoh 9136246
Immutability for blake2 + test_freeze module
matajoh 61a0400
Fixing some holes in object/typeobject
matajoh 6a6b04b
Remove immutable keys from dictionary as no longer required
mjp41 0caa788
Dealing with buffer immutability
matajoh a5ceb51
_ctypes immutability
matajoh 2e54f32
_decimal
matajoh 32d3fe7
Adding a NotFreezable type
matajoh 37f2d76
_io
matajoh fe5de34
Fixing some broken tests
matajoh fef1fdb
Fixing the name of NotWritableError
matajoh ab10e21
_multiprocessing _sqlite3
matajoh a7dbd1a
cjkcodecs
matajoh dd611e4
_abc
matajoh 47fab24
_asyncio
matajoh 99f259c
Fixing import error
matajoh 4f7816a
bz2
matajoh 09fb9a7
_collections _csv
matajoh 11119d0
Moving Py_Freeze to public API
matajoh baff5f8
xxlimited, xxsubtype, zlib
xFrednet 93eca6d
_dbm etree
matajoh 2ab77d3
immutable module
matajoh a4d42da
All tests passing again
matajoh 5a0b5b7
_datetime
matajoh 2fab5cd
_struct
matajoh f621a0c
Making freezable types a weakset
matajoh a31e962
These don't need to be freezable
matajoh adc1319
Make mutable during finalisation. (#6)
mjp41 ccb893c
Dealing with more finalisation bugs
matajoh 30dd83f
Shadow cell
matajoh 57df4db
Removing isfreezable and adding some TODOs
matajoh 4866d04
Using import helper
matajoh 0387c12
Adding the bases tuple as discussed
matajoh c867271
Initial simple Python module.
81aebf3
Add .clang-format file.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,232 @@ | ||
| # Reference: https://clang.llvm.org/docs/ClangFormatStyleOptions.html | ||
| Language: Cpp | ||
| BasedOnStyle: Google | ||
| AccessModifierOffset: -4 | ||
| AlignAfterOpenBracket: Align | ||
| AlignArrayOfStructures: Left | ||
| AlignConsecutiveAssignments: None | ||
| AlignConsecutiveBitFields: AcrossEmptyLines | ||
| AlignConsecutiveDeclarations: None | ||
| AlignConsecutiveMacros: Consecutive | ||
| AlignEscapedNewlines: Right | ||
| AlignOperands: Align | ||
| AlignTrailingComments: | ||
| Kind: Always | ||
| OverEmptyLines: 1 | ||
| AllowAllArgumentsOnNextLine: false | ||
| AllowAllParametersOfDeclarationOnNextLine: false | ||
| AllowBreakBeforeNoexceptSpecifier: OnlyWithParen | ||
| AllowShortBlocksOnASingleLine: Never | ||
| AllowShortCaseExpressionOnASingleLine: true | ||
| AllowShortCaseLabelsOnASingleLine: false | ||
| AllowShortCompoundRequirementOnASingleLine: true | ||
| AllowShortEnumsOnASingleLine: true | ||
| AllowShortFunctionsOnASingleLine: All | ||
| AllowShortIfStatementsOnASingleLine: Never | ||
| AllowShortLambdasOnASingleLine: All | ||
| AllowShortLoopsOnASingleLine: true | ||
| AlwaysBreakAfterDefinitionReturnType: None | ||
| AlwaysBreakBeforeMultilineStrings: true | ||
| BinPackArguments: true | ||
| BinPackParameters: false | ||
| BitFieldColonSpacing: None | ||
| BraceWrapping: | ||
| AfterCaseLabel: false | ||
| AfterClass: false | ||
| AfterControlStatement: Never | ||
| AfterEnum: false | ||
| AfterExternBlock: false | ||
| AfterFunction: true | ||
| AfterNamespace: false | ||
| AfterObjCDeclaration: false | ||
| AfterStruct: false | ||
| AfterUnion: false | ||
| BeforeCatch: true | ||
| BeforeElse: true | ||
| BeforeLambdaBody: false | ||
| BeforeWhile: false | ||
| IndentBraces: false | ||
| SplitEmptyFunction: true | ||
| SplitEmptyRecord: true | ||
| SplitEmptyNamespace: true | ||
| BreakAdjacentStringLiterals: true | ||
| BreakAfterAttributes: Leave | ||
| BreakAfterReturnType: AllDefinitions | ||
| BreakBeforeBinaryOperators: NonAssignment | ||
| BreakBeforeConceptDeclarations: Always | ||
| BreakBeforeBraces: Custom | ||
| BreakBeforeInlineASMColon: OnlyMultiline | ||
| BreakBeforeTernaryOperators: true | ||
| BreakConstructorInitializers: BeforeColon | ||
| BreakFunctionDefinitionParameters: false | ||
| BreakInheritanceList: BeforeColon | ||
| BreakStringLiterals: true | ||
| BreakTemplateDeclarations: Yes | ||
| ColumnLimit: 79 | ||
| CompactNamespaces: false | ||
| ConstructorInitializerIndentWidth: 4 | ||
| ContinuationIndentWidth: 4 | ||
| Cpp11BracedListStyle: false | ||
| DerivePointerAlignment: true | ||
| EmptyLineAfterAccessModifier: Never | ||
| EmptyLineBeforeAccessModifier: LogicalBlock | ||
| FixNamespaceComments: true | ||
| IncludeBlocks: Regroup | ||
| IncludeCategories: | ||
| - Regex: '^[<"]Python\.h[">]$' | ||
| Priority: 2 | ||
| CaseSensitive: true | ||
| - Regex: '^<[[:alnum:]_/]+(\.h)?>$' | ||
| Priority: 1 | ||
| - Regex: '^"cpython/.*\.h"$' | ||
| Priority: 3 | ||
| CaseSensitive: true | ||
| - Regex: '^"pycore.*\.h"$' | ||
| Priority: 4 | ||
| CaseSensitive: true | ||
| - Regex: '.*' | ||
| Priority: 5 | ||
| IndentAccessModifiers: false | ||
| IndentCaseBlocks: false | ||
| IndentCaseLabels: true | ||
| IndentExternBlock: NoIndent | ||
| IndentGotoLabels: false | ||
| IndentPPDirectives: None | ||
| IndentRequiresClause: true | ||
| IndentWidth: 4 | ||
| IndentWrappedFunctionNames: false | ||
| InsertBraces: true | ||
| InsertNewlineAtEOF: true | ||
| InsertTrailingCommas: None | ||
| KeepEmptyLines: | ||
| AtEndOfFile: false | ||
| AtStartOfBlock: false | ||
| AtStartOfFile: false | ||
| LambdaBodyIndentation: Signature | ||
| LineEnding: DeriveLF | ||
| MacroBlockBegin: '' | ||
| MacroBlockEnd: '' | ||
| Macros: | ||
| - >- | ||
| PyObject_HEAD_INIT(type)={ | ||
| /* this is not exactly match with PyObject_HEAD_INIT in Python source code | ||
| * but it is enough for clang-format */ | ||
| { 0xFFFFFFFF }, | ||
| (type) | ||
| }, | ||
| - >- | ||
| PyVarObject_HEAD_INIT(type, size)={ | ||
| { | ||
| /* manually expand PyObject_HEAD_INIT(type) above | ||
| * because clang-format do not support recursive expansion */ | ||
| { 0xFFFFFFFF }, | ||
| (type) | ||
| }, | ||
| (size) | ||
| }, | ||
| # Add indentation for aligning parameters when the definition spans multiple lines. | ||
| - PyAPI_FUNC(RTYPE)=extern RTYPE /* */ | ||
| # Add a qualifier to properly indent right aligned pointer macro PyAPI_DATA(PyObject *) | ||
| # This is a workaround for clang-format and has no effect on the formatted code. | ||
| - PyAPI_DATA(RTYPE)=extern RTYPE const | ||
| - PyMODINIT_FUNC=PyObject * | ||
| MainIncludeChar: Quote | ||
| MaxEmptyLinesToKeep: 2 | ||
| NamespaceIndentation: None | ||
| PackConstructorInitializers: NextLine | ||
| PenaltyBreakAssignment: 20 | ||
| PenaltyBreakBeforeFirstCallParameter: 1 | ||
| PenaltyBreakComment: 300 | ||
| PenaltyBreakFirstLessLess: 120 | ||
| PenaltyBreakOpenParenthesis: 0 | ||
| PenaltyBreakScopeResolution: 500 | ||
| PenaltyBreakString: 1000 | ||
| PenaltyBreakTemplateDeclaration: 10 | ||
| PenaltyExcessCharacter: 1000000 | ||
| PenaltyIndentedWhitespace: 0 | ||
| PenaltyReturnTypeOnItsOwnLine: 1000000000 | ||
| PointerAlignment: Right | ||
| PPIndentWidth: -1 | ||
| QualifierAlignment: Custom | ||
| QualifierOrder: | ||
| [friend, static, inline, const, constexpr, volatile, type, restrict] | ||
| ReferenceAlignment: Right | ||
| ReflowComments: false | ||
| RemoveBracesLLVM: false | ||
| RemoveParentheses: MultipleParentheses | ||
| RemoveSemicolon: true | ||
| RequiresClausePosition: OwnLine | ||
| RequiresExpressionIndentation: OuterScope | ||
| SeparateDefinitionBlocks: Leave | ||
| ShortNamespaceLines: 1 | ||
| SkipMacroDefinitionBody: false | ||
| SortIncludes: CaseSensitive | ||
| SortUsingDeclarations: LexicographicNumeric | ||
| SpaceAfterCStyleCast: false | ||
| SpaceAfterLogicalNot: false | ||
| SpaceAfterTemplateKeyword: true | ||
| SpaceAroundPointerQualifiers: Default | ||
| SpaceBeforeAssignmentOperators: true | ||
| SpaceBeforeCaseColon: false | ||
| SpaceBeforeCpp11BracedList: false | ||
| SpaceBeforeCtorInitializerColon: true | ||
| SpaceBeforeInheritanceColon: true | ||
| SpaceBeforeJsonColon: false | ||
| SpaceBeforeParens: ControlStatements | ||
| SpaceBeforeRangeBasedForLoopColon: true | ||
| SpaceBeforeSquareBrackets: false | ||
| SpaceInEmptyBlock: false | ||
| SpacesBeforeTrailingComments: 2 | ||
| SpacesInAngles: Never | ||
| SpacesInContainerLiterals: true | ||
| SpacesInLineCommentPrefix: | ||
| Minimum: 1 | ||
| Maximum: -1 | ||
| SpacesInParens: Never | ||
| SpacesInSquareBrackets: false | ||
| Standard: c++11 | ||
| StatementAttributeLikeMacros: | ||
| # Defined in Include/pyport.h | ||
| - Py_DEPRECATED | ||
| - _Py_HOT_FUNCTION | ||
| - Py_ALWAYS_INLINE | ||
| - Py_NO_INLINE | ||
| - Py_ALIGNED | ||
| - Py_GCC_ATTRIBUTE | ||
| - _Py_NO_RETURN | ||
| - _Py_FALLTHROUGH | ||
| StatementMacros: | ||
| - PyObject_HEAD | ||
| - PyObject_VAR_HEAD | ||
| - PyException_HEAD | ||
| - _PyTZINFO_HEAD | ||
| - _PyDateTime_TIMEHEAD | ||
| - _PyDateTime_DATETIMEHEAD | ||
| - _PyGenObject_HEAD | ||
| - Window_NoArgNoReturnFunction | ||
| - Window_NoArgTrueFalseFunction | ||
| - Window_NoArgNoReturnVoidFunction | ||
| - Window_NoArg2TupleReturnFunction | ||
| - Window_OneArgNoReturnVoidFunction | ||
| - Window_OneArgNoReturnFunction | ||
| - Window_TwoArgNoReturnFunction | ||
| TableGenBreakInsideDAGArg: DontBreak | ||
| TabWidth: 4 | ||
| TypeNames: | ||
| # Defined in Include/pytypedefs.h | ||
| - PyModuleDef | ||
| - PyModuleDef_Slot | ||
| - PyMethodDef | ||
| - PyGetSetDef | ||
| - PyMemberDef | ||
| - PyObject | ||
| - PyLongObject | ||
| - PyTypeObject | ||
| - PyCodeObject | ||
| - PyFrameObject | ||
| - PyThreadState | ||
| - PyInterpreterState | ||
| UseTab: Never | ||
| WhitespaceSensitiveMacros: | ||
| - _Py_XSTRINGIFY | ||
| - Py_STRINGIFY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #ifndef Py_CPYTHON_IMMUTABLE_H | ||
| # error "this header file must not be included directly" | ||
| #endif | ||
|
|
||
| PyAPI_DATA(PyTypeObject) _PyNotFreezable_Type; | ||
|
|
||
| PyAPI_FUNC(int) _PyImmutability_Freeze(PyObject*); | ||
| PyAPI_FUNC(int) _PyImmutability_RegisterFreezable(PyTypeObject*); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #ifndef Py_IMMUTABILITY_H | ||
| #define Py_IMMUTABILITY_H | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
|
|
||
| #ifndef Py_LIMITED_API | ||
| # define Py_CPYTHON_IMMUTABLE_H | ||
| # include "cpython/immutability.h" | ||
| # undef Py_CPYTHON_IMMUTABLE_H | ||
| #endif | ||
|
|
||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif /* !Py_IMMUTABILITY_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #ifndef Py_INTERNAL_IMMUTABILITY_H | ||
| #define Py_INTERNAL_IMMUTABILITY_H | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| #ifndef Py_BUILD_CORE | ||
| # error "Py_BUILD_CORE must be defined to include this header" | ||
| #endif | ||
|
|
||
| struct _Py_immutability_state { | ||
| PyObject *module_locks; | ||
| PyObject *blocking_on; | ||
| PyObject *freezable_types; | ||
| PyObject *destroy_cb; | ||
| }; | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif /* !Py_INTERNAL_IMMUTABILITY_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that different interpreters have different views on what is freezable?